|
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]
|