BillyRayPreachersSon
Programmer
I was thinking about this earlier, and thought I'd open it up for discussion - just to see what people thought.
If you have some CSS that affects an element with a certain ID, for example:
Code:
#myId {
background-color: red;
}
...
<div id="myId">Hello World!</div>
then the div would have a red background. If that div were within another div, we could also use this:
Code:
#myContainer #myId {
background-color: red;
}
...
<div id="#myContainer">
<div id="myId">Hello World!</div>
</div>
However, even if the "#myContainer" is not included in the style sheet, the "#myId" div will still be affected.
So the questions: even though in that situation, the first id would not be needed, would you, and do you think it could be beneficial to put it in for clarity?
For example, if the outer id was the id of an element containing a section of the page, it could certainly make it easier to know what section the inner div was in. I guess you could argue that if the inner div had a meaningful id anyway, that would not be necessary.
Just wondering where people stood on this!
Dan