Hi,
Some precisions:
The * is called the universal selector as it acts like a wildcard, matching all the available elements.
Ex. of use:
* {
margin: 0;
padding: 0;
}
This code set all margins/padding to zero.
Used with html, it’s a hack named The Star HTML hack.
It targets an HTML element enclosed inside another element.
This only happens in IE 6 (and below) as these browsers have an anonymous root element wrapping around the HTML element (thanks M. Microsoft).
(mainly from CSS Mastery written by Andy BUDD).
This is a very useful bit of code, used to reset everything that a
browser might do by default back to “known base” values. Then you
build up from there, adding padding and margins to elements that you
want to style. This keeps the page looking the way you expect in as
many browsers as possible.
So for example in my IE5 stylesheet could I add the below CSS then go
back through and add the proper margins and paddings to each element
and/or style. Am I understanding that correctly?
Todd
On Nov 2, 2007, at 12:53 PM, Walter Lee Davis wrote:
On Nov 2, 2007, at 1:28 PM, JJBee wrote:
Ho la la,
Sorry the … BBCode tags.
The CSS is
{
margin: 0;
padding: 0;
}
This is a very useful bit of code, used to reset everything that a
browser might do by default back to “known base” values. Then you
build up from there, adding padding and margins to elements that you
want to style. This keeps the page looking the way you expect in as
many browsers as possible.
So for example in my IE5 stylesheet could I add the below CSS then go
back through and add the proper margins and paddings to each element
and/or style. Am I understanding that correctly?
Todd
Yes. I just followed the link that JJBee posted, it’s quite a romp
through the code – you should read the page and the comments.
The idea is that there are dozens of little quirks hiding in the
browsers’s default stylesheets (the properties that they will each
apply to the basic building blocks of the HTML page). If you don’t
write stylesheets that provide some value for each and every single
property of these elements (and nobody does, usually) then you will
at some point, in some browser, end up seeing these defaults instead
of the defaults of the browser you used to proof your work. This in
turn will cause your layout to be different that you expect in that
foreign browser.
Now if you do reset everything, you have to add it all back.
Otherwise you end up with a page that looks like all the text crashed
into each other. But if you do, then you will know what size
everything will end up being.
Sometime around 2/11/07 (at 14:39 -0400) JJBee said:
Beside that, it seems like BBCode tags work so sorry for my useless
previous post.
BBCode tags don’t work in my email - I would appreciate it if people
just post the full-qualified URL itself rather than trying funky
pseudo-code stuff. Ta!