You are here: Re: id selectors; p#para1, what use of? « HTML « IT news, forums, messages
Re: id selectors; p#para1, what use of?

Posted by Els on 12/18/07 21:35

guiderocksalt@yahoo.com wrote:

> New to this....
>
> If there can be only one unique id on a page, then what is the use of
> this?:
>
> From W3Schools ===========================
> The style rule below will match the p element that has an id with a
> value of "para1":
>
> p#para1
> {
> text-align: center;
> color: red
> }
> =========================================
>
> para1 can only exist in one element... correct?

On that html page, yes.
But the stylesheet could also reference a div#para1 that is in the
html on a different page on the same site. Then #para1 would apply to
both the paragraph on one page, and the div on another. Adding the p
will prevent that.

For myself though, the reason to write p#para1 instead of just #para1,
would be that by looking at the stylesheet, I can instantly see that
it is a paragraph that's being referenced, not a div or a span or
anything else.

--
Els http://locusmeus.com/

 

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

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