CSS reset

CSS reset

avoiding browser defaults by using the * (global) selector

·

1 min read

We can use the global sector, *, to set our own default values:

* {
    border: 0;
    margin: 0;
    padding: 0;
}

...which ensures that we have no borders, margins or paddings for any elements unless we specific them in our CSS!

We can also use this selector to add another important property called box-sizing:

* {
    ...
    box-sizing: border-box;
}

The border-box value ensures that a child element with a width of 100% fits entirely within the parent's borders ... (by default, the child element's width would include the borders!)