To dot or not to dot?

S

Samuël van Laere

I've seen both methods used:

#something .label {
color: #000;
}

and

#something label {
color: #000;
}

Or are both acceptable?
Or should i use one in particular?
 
A

Adrienne

I've seen both methods used:

#something .label {
color: #000;
}

and

#something label {
color: #000;
}

Or are both acceptable?
Or should i use one in particular?

# indicates an id, . indicates a class, (nothing) indicates an element.
 
S

Samuël van Laere

Adrienne said:
Gazing into my crystal ball I observed "Samuël van Laere"
<[email protected]> writing in @amsnews02.chello.com:

# indicates an id, . indicates a class, (nothing) indicates an element.
Ok so:

#something .label {
color: #000;
}

is an ID despite of the dot before the 'label' ?
If that is so then a dot isn't needed.
The validator doesn't seem to care either,
so what ever i use it seems to be correct anyway.


Thanks for the information Adrienne.
 
R

Richard

Samuël van Laere said:
I've seen both methods used:
#something .label {
color: #000;
}

#something label {
color: #000;
}
Or are both acceptable?
Or should i use one in particular?

The way I see it, they were given as methods to be employed as a users
choice.
While some will argue the point that only 1 # should be used.
Well duh, if it saves space to say "id" rather than "class", would you print
out your name as "mister" rather than "mr."?
If the system supports more than one ID, then by all means, use it.
 
M

Mark Parnell

Sometime around Thu, 16 Oct 2003 02:16:05 GMT, Samuël van Laere is reported
to have stated:
Ok so:

#something .label {
color: #000;
}

is an ID despite of the dot before the 'label' ?

No. <pedantic>It is a style rule</pedantic>. :) It means apply this
rule to any element with class="label" that is a child of an element with
id="something".
If that is so then a dot isn't needed.

It depends whether you are trying to apply the rule to an element with
class="label" or a label element.
The validator doesn't seem to care either,

Both are valid, so it shouldn't.
so what ever i use it seems to be correct anyway.

Valid, yes. Correct no. As above, it depends what you are trying to do.
(Of course, if you have <label...class="label"> then either will work, but
that would seem a little pointless).
 
L

Leif K-Brooks

Richard said:
If the system supports more than one ID, then by all means, use it.

Yes, then you notice that your browser isn't the only one in the world.
 
R

Richard

Samuël van Laere wrote:

Adrienne said:
Gazing into my crystal ball I observed "Samuël van Laere"
<[email protected]> writing in @amsnews02.chello.com:

# indicates an id, . indicates a class, (nothing) indicates an
element.
#something .label {
color: #000;
}
is an ID despite of the dot before the 'label' ?
If that is so then a dot isn't needed.
The validator doesn't seem to care either,
so what ever i use it seems to be correct anyway.

Thanks for the information Adrienne.

#something label{}
No dot needed.
In actuality, it shoul read something like div#label{}.
Meaning, ID "label" is used primarily in <div> tags.
<div id="label">
Would be valid whereas, <table id="label"> could be invalid.
 
T

Toby A Inkster

Both mean different things...

Samuël van Laere said:
#something .label {
color: #000;
}

This would match:

<div id="something">
<p><em class="label">Hello</em></p>
</div>

or

<div id="something">
<p class="label">Hello</p>
</div>

That is, it matches elements with class="label".
#something label {
color: #000;
}

This would match:

<p id="something">
<label for="foobar">Name</label>
</p>

That is, it matches <label> elements.
 
S

Samuël van Laere

Thanks for the explanation people now i know
what the difference is and how to use it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top