9 replies [Last post]
Jnz
Offline
newbie
Last seen: 15 years 22 weeks ago
Timezone: GMT+2
Joined: 2005-03-05
Posts: 7
Points: 0

Hi,
i was searching in google but coundn't find it, so here it comes:

what does this mean:

* html body .class
{
...
}

"*" - what it meas?
also:

html > .class
{
...
}

">" - what it meas?

Anybody know ? Link would be great...
Thanks...

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 5 years 30 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

> and * in CSS ?

Well I googled on 'css selectors' many links, try the first one is well known and pretty authorative, can't believe you couldn't find these :roll:.

The,

* html #somedivid {}

is actually a hack and is using IE incorrect handling of this '*' selector, which is the 'universal' selector a wild card so to speak and selects any element, technically you can not select any element that precedes the root html element it's the topmost part of the DOM

This rule would be ignored by all modern browsers except IE which will process the rule set, thus it's a method of feeding rules to IE only.

The other I'll leave to you to google for and read up on Wink

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

euio
Offline
Enthusiast
Last seen: 15 years 22 weeks ago
Timezone: GMT+8
Joined: 2005-03-03
Posts: 71
Points: 0

> and * in CSS ?

Hugo wrote:

This rule would be ignored by all modern browsers except IE which will process the rule set, thus it's a method of feeding rules to IE only.

so can we do something like

* {
padding: 0;
margin: 0;
}

is that acceptable? because it starts to annoy me when i add margin 0 and padding 0 to all the elements... Laughing out loud Laughing out loud

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 7 years 1 week ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

> and * in CSS ?

If you read the fourth post down in this thread > http://www.csscreator.com/css-forum/ftopic8507.html you'll see that Seb has his own way of doing something similar, which he calls 'nuking' the page. This resets all the defaults for all of the main selectors in all of the different browsers. AFAIK your idea will fail as you need to tell the browser which selectors to apply your properties to.

Life's a b*tch and then you die!

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 5 years 30 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

> and * in CSS ?

euio,
This is actually a useful method - and becoming more widely known/used - of getting around the different margin/padding defaults between browsers and makes a lot of sense to level the playing field so to speak to begin with and then to add the margin/padding actually required, especially useful in the case of ul/ol elements.

There is also a method that suggests zeroing the margin/padding and then setting your own defined margin for grouped elements, so that your working from a unified value for browsers, something like this
h1, h2, h3, h4, h5, h6, p, pre, blockquote, label, ul, ol, dl { margin:1.em 5% ; }

Although I'm not yet convinced I prefer this to just setting margins where I need them , having globally zeroed them first.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

euio
Offline
Enthusiast
Last seen: 15 years 22 weeks ago
Timezone: GMT+8
Joined: 2005-03-03
Posts: 71
Points: 0

> and * in CSS ?

Quote:
AFAIK your idea will fail as you need to tell the browser which selectors to apply your properties to.

i just got the idea from http://leftjustified.net/journal/2004/10/19/global-ws-reset/ :oops: :oops: Laughing out loud

Quote:

Although I'm not yet convinced I prefer this to just setting margins where I need them , having globally zeroed them first.

in other words, Laughing out loud it is somehow ideal to use that... i only used the

* html

when i need to get a centered and a 100% height of a container as suggested by somebody-i-forgot-who...

* html #container { height:100% }

but is it possible to just put

* #container {height:100%}

provided the container is not a descendant of any divs but of <body> and <html> only?

Jnz
Offline
newbie
Last seen: 15 years 22 weeks ago
Timezone: GMT+2
Joined: 2005-03-05
Posts: 7
Points: 0

&gt; and * in CSS ?

HI,
aaa, that thing is called selector ? Thats why i could find anything on google, i didn't knew how it is named...
Well, anyways thanks for info...

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 7 years 1 week ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

&gt; and * in CSS ?

euio wrote:
i just got the idea from http://leftjustified.net/journal/2004/10/19/global-ws-reset/ :oops: :oops: Laughing out loud

When you've just read an entire detailed page all about an idea (with comments); why then ask us if it is acceptable? If you're going to do that, at least include the link with your question :roll:

Life's a b*tch and then you die!

euio
Offline
Enthusiast
Last seen: 15 years 22 weeks ago
Timezone: GMT+8
Joined: 2005-03-03
Posts: 71
Points: 0

&gt; and * in CSS ?

Laughing out loud i simply was uncertain about their status as web developers... I just wanted to hear from the 'gurus' themselves... sorry but none of great web developers is familiar to me and a only handful, mostly in this forums, would convince me they are skilled enough... and your status as 'guru' here in a very well respected forums just earned my trust... Laughing out loud also especially those comments in the link are unlikely credible for me sorry... and for me, csscreator's forum is a source of help for those who are weak, that's its sole purpose i believe... im just being wise when consuming knowledge... :roll: :roll: :roll: :roll:

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 7 years 1 week ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

&gt; and * in CSS ?

eulo - your supportive words about this forum are kind, encouraging and will be appreciated by all the regulars I'm sure.

Personally, I help out on this forum in order to teach AND learn (mostly the later) so that I can be more effective in my role as a web developer and design professional. So I am grateful for the fact that you brought this (new to me) use of the star selector to my attention, but would have preferred it if you had said something like: "I've just read this article > [ link ] and am wondering if the regulars on this forum feel that this method of dealing with differing default margin and padding values is good practice." That way I and others can benefit from the thoughts and findings of others BEFORE we make an off-the-cuff remark that later makes us feel foolish :oops:

I did not think that your *{} suggestion would work because I did not fully understand the star selector, but having now read the full blog-article, I can see that it should and does work, subject to a few well-explained problems. In fact, it seems to be exactly the sort of use that the star selector was created for!

Yet again, some of the best ideas are the simplest Smile

As for my guru status: although there are clearly many regulars on this forum (gurus and non-gurus) that really know their stuff with regards to CSS, I have to think that my status was awarded by Tony (the founder of this forum) due to my wide ranging but more generalised knowledge of the web, design and commerce. I am not a CSS guru by a long shot.

Moving back on topic now: does anybody else (e.g. Tony, Hugo, DC, Gary etc.) have anything to add to the opinions and techniques described in eulo's link as I for one can now see an opportunity to make my style-sheets that much more leaner and efficient through what appears to me to be the correct use of the star selector.

Life's a b*tch and then you die!