SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Oct 7, 2007, 17:32 #1
- Join Date
- Oct 2006
- Posts
- 216
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
noob: css declaration #content vs div#content?
Are they the same?
-
Oct 7, 2007, 17:43 #2
- Join Date
- Jun 2007
- Location
- San Diego, CA
- Posts
- 784
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
basically yes. An id can only be applied to one element per page, so it's going to be a div.
There is a situation where they'd be very different. If you're using an external stylesheet and on some pages #content is the id of a div and on some pages it's not. In that case #content would implement style rules that you want to apply anywhere you use id="content", regardless of the element it's attached to. And div #content would be the style rules that only apply to divs with the content id.Whatever you can do or dream you can, begin it.
Boldness has genius, power and magic in it. Begin it now.
Chroniclemaster1, Founder of Earth Chronicle
A Growing History of our Planet, by our Planet, for our Planet.
-
Oct 7, 2007, 21:31 #3
- Join Date
- Jan 2005
- Location
- md
- Posts
- 180
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Oct 7, 2007, 21:45 #4
- Join Date
- Dec 2003
- Location
- USA
- Posts
- 2,582
- Mentioned
- 29 Post(s)
- Tagged
- 0 Thread(s)
If it is "div #content" it means "a div element with the id content", where as "#content" is "any element with the id content".
Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass
-
Oct 8, 2007, 07:53 #5
- Join Date
- Feb 2006
- Posts
- 62
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If it is "div #content" it means "a div element with the id content"
div#content is what you described: "a div element with the id content"
John
-
Oct 8, 2007, 21:19 #6
- Join Date
- Dec 2003
- Location
- USA
- Posts
- 2,582
- Mentioned
- 29 Post(s)
- Tagged
- 0 Thread(s)
Oops, yup, that was a typo.
"div #content" would mean "An element with the id of content contained within a div, regardless of how deep"
And, while we're at it "div>#content" would mean "An element with the id of content contained directly within a div"Xazure.Net - My Blog - About Programming and Web Development
Follow Me on Twitter!
Christian Snodgrass
Bookmarks