You are here: Re: css - nested id's ? « HTML « IT news, forums, messages
Re: css - nested id's ?

Posted by Toby Inkster on 02/14/06 10:26

julian_m wrote:

> Why div#roundedbox ? Is it the same as #roundedbox?

Not quite. You might have:

<div id="roundedbox">...</div>
<h2 id="roundedbox">...</h2>

(On different pages, naturally, as you can only use an ID once per page!)

div#roundedbox only matches the former example.

> What is div#roundedbox #top

It would match:

<div id="roundedbox"><p id="top">here</p></div>
or
<div id="roundedbox"><p><b id="top">here</b></p></div>

but

<div id="roundedbox"></div><p id="top">not here</p>
and
<p id="roundedbox"><b id="top">not here</b></p>

> It seems as some kind of hierarchy between roundedbox and top..

I think you should read:
http://www.w3.org/TR/CSS21/selector.html

> Wouldn't be the same div#top or just simply #top (given that both are
> ID's)?

No -- they are less specific -- though for many documents, they may end up
selecting the same elements.

> How can I do to achieve the same but using classes instead of id.
> Note that I'll use the code more than once in my html...

div.roundedbox .top { do: something; }
..roundedbox .top { do: something; }
#roundedbox .top { do: something; }

and so on. Read the link I posted above.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация