Valid CSS or Hack?

Put this at the top of your CSS file:

* { margin: 0; padding: 0; }  

hack? or valid CSS? What does it do? and how is it transferred to different browsers / versions?

+3
source share
7 answers

This is valid CSS. It selects an EVERY element and resets the default field values ​​and paddings. The reason people use this is to make their site layout more consistent across browsers / versions, as each browser has its own default stylesheet. If you do not use this declaration or specify margin / padding for each element, each browser will use its own default paddings / padding for this element, and the page will be displayed inconsistently in different browsers.

+25

CSS. . . . - , (, , ), , .

. . ( , , 2000 , , .)

Internet Explorer 5.x Macintosh, IE 4.5 Mac, Opera 3.6. Netscape 6 Preview 1 , 3 Opera 4 Windows.

+2

:

  • CSS
  • "".
  • , ,

* - . CSS 0000, , . , "reset" , .

, . . , , .

. div, li .. , , , a span head. , .

reset HTML, - Eric Meyer Reset CSS. reset CSS , . , . ( body h1, .)

+1

:

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

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

. -, .

, , HTML - . CSS reset.

, CSS.

+1

CSS, .

reset HTML, . reset, , .

0

. . "css reset"

As tf111 explains, the idea is to get rid of certain browser options for margins and padding, which are different in all browsers.

0
source

Source: https://habr.com/ru/post/1708851/


All Articles