Chapter 25. Controlling Design Space with HTML


By default, Web browsers put some extra whitespace between the browser interface and the start of the page. This comes in handy when you have a text-only Web page, but many types of designsespecially liquid layoutsdon't feel right with the extra padding.

FAQ

What happens to the values that the browser doesn't understand?

IE and Netscape ignore the attributes that they don't understand, so you aren't really creating compatibility problems by setting all four attributes.


You can turn off the extra padding by setting a couple of attributes in the body tag to 0. Which attributes you use depends on the browser. In Internet Explorer, the appropriate attributes are leftmargin and topmargin:

 <body leftmargin="0" topmargin="0"> 

In Netscape browsers, the attributes are marginwidth and marginheight:

 <body marginwidth="0" marginheight="0"> 

If you're smart, you'll use all four:

 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 

Conversely, you can create extra padding by setting these attributes to nonzero values. The leftmargin and topmargin attributes in IE control the amount of spacing along the left and top of the browser window, respectively, but do nothing to the right and bottom, while the Netscape attributes supply spacing equally to the left and right with marginwidth and to the top and bottom with marginheight.

Remember, IE doesn't understand the Netscape attributes and vice versa, so you can't get extra right-margin padding by setting marginwidth in IE. Likewise, you can't affect the left side of the browser window only by setting leftmargin in Netscape.

For a better level of margin control overall, try using CSS instead of HTML (see Topic 26).



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net