What is the purpose of this CSS snippet?

I have the following snippet in my stylesheet. What is the impact or purpose?

* { margin:0; padding:0; top: 0px; left: 0px; } 
+8
html css
source share
5 answers

This is reset CSS . The goal is to remove non-zero default intervals for all elements ( * ). All browsers have a default stylesheet, and they are not very consistent with each other. Take <form> as an example.

Note. Setting the left and top properties to 0px not suitable for me. This is likely to cause problems with absolute positioning. When positioning an element, you can only determine its vertical or horizontal offset (not both), leaving the other offset unchanged. This reset CSS does not allow this because it gives values ​​for both vertical and horizontal. You can also place an element below. If you have a reset, it will have both bottom and top , which in most cases is not needed and can change the height of the element or ignore one of the offsets. In any case, this will give you something inappropriate and will not break your layout.

For those who want to know more: http://www.w3.org/TR/CSS2/visuren.html#absolute-positioning

+8
source share

This is reset. After that, all elements will have 0 fields, indents, etc.

Such resets are useful for normalizing behavior (some browsers have predefined fields, paddings, etc.) and for increasing the consistency of visual characteristics in browsers.

+11
source share

It applies the rules contained in all elements of the page; creating a predictable foundation for cascading rules.

This method is called "reset" (google for "CSS Reset") and is an approach to solving different browsers using different CSS rules by default.

These rules should be applied as early as possible, usually at the beginning of the first CSS sheet loaded.

+1
source share

The purpose of your snippet is to reset the fields, fill and adjust the position in the upper left corner of the viewport in your web browser.

0
source share

The Estric symbol is known as all / all, so the point of this is CSS, which will be implemented on all elements and sets the values ​​as parameters.

0
source share

All Articles