If you??™re not sure how to work with the different types of links??”absolute, relative,
and root-relative??”read the guide in Chapter 5, at the beginning of the ???Creating and
styling web page links??? section.
You may have seen the language attribute used within script start tags, but this is
deprecated and won??™t validate if you??™re using XHTML Strict.
THE ESSENTIAL GUIDE TO CSS AND HTML WEB DESIGN
42
Furthermore, in terms of page weight, CSS is more efficient. If using old methods, to cater
for all browsers, you set the following body attributes:
?? bottommargin="0" rightmargin="0">
The equivalent in CSS is the following:
body {
margin: 0;
padding: 0;
}
The reason both margin and padding are set to 0 is because some browsers define a
default padding value. Therefore, even if you set all body margins to 0, there would still be
a gap around your page content. Setting both the margin and padding to 0 in the body rule
ensures that all browsers display your content with no gaps around it.
Zeroing margins and padding on all elements
Although the previous block of code is clean and efficient, it isn??™t something I use in my
websites. The reason for this is that browsers place default (and sometimes varying)
margins around various elements other than the page??™s body, too. Therefore, my CSS
boilerplates always include the following:
* {
margin: 0;
padding: 0;
}
The selector, *, is the universal selector, and the declaration therefore applies to all elements
on the web page.
Pages:
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106