HighDots Forums  

Re: div#header vs. #header

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Re: div#header vs. #header in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Johannes Baagoe
 
Posts: n/a

Default Re: div#header vs. #header - 09-25-2007 , 10:10 AM






William Gill :

Quote:
If I use the selector #header, it will match any any element that is
identified as "header".
Quite, but there should be at most one in your document, so the "any" part
is a bit misleading. It is like saying, e.g., "Any URL which is identical
to http://www.w3c.org/ points to the web site of the World Wide Web
Consortium".

--
Johannes
"Quand on dit c'est un Johannes, cela vaut autant que ce que maintenant
on appelle un pédant" (H. Estienne, in É. Littré, /Dictionnaire de la
langue française/, art. PÉDANT)


Reply With Quote
  #12  
Old   
Johannes Baagoe
 
Posts: n/a

Default Re: div#header vs. #header - 09-25-2007 , 10:07 PM






William Gill :

Quote:
Is this any clearer?

"If I use the selector #header, it will match an element of any type
that has been identified as "header", if one exists."
Much clearer :-)

I was wondering if you were somehow trying to distinguish between
different types of elements with the same id attribute in the same
document. That would have been silly, of course, but I have seen worse
questions asked.

Anyway, as I understand the specs, div#x is more specific than #x, so it
wins in the rather unlikely case one would bother to write both.

Specifically :-), "#x" would have a specificity of a=0 b=1 c=0 d=0 ->
0,1,0,0 while "div#x" would have a specificity of a=0 b=1 c=0 d=1 ->
0,1,0,1 (http://www.w3.org/TR/CSS21/cascade.html#specificity)


--
Johannes
"Quand on dit c'est un Johannes, cela vaut autant que ce que maintenant
on appelle un pédant" (H. Estienne, in É. Littré, /Dictionnaire de la
langue française/, art. PÉDANT)


Reply With Quote
  #13  
Old   
Jonathan N. Little
 
Posts: n/a

Default Re: div#header vs. #header - 09-26-2007 , 01:03 PM



William Gill wrote:
Quote:
Jonathan N. Little wrote:

I personally would use #withid and would only preface with the element
type if the rule contained a property that related specifically to
that element. e.g.,

ul#withid { list-style: none; }
#withid { color: red; background-color: white; }

Thank you Jonathan, and what I was trying to make figure out was, if I
willingly sacrifice that flexibility in order to give myself a crutch
(i.e. a reminder of the element the style was being applied to), what
other unintended consequence might I create.
Well I would say as a "crutch" use a comment! I believe in comments, a
create tool from programming background. Even if you will be the only
one maintaining code of any sort, a comment can save countless hours of
head-scratching when your need to fix or update many months|years down
the road.

/* outer DIV for formating the main page content */
#wrapper {...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.