Okay, the html document has these elements:
<p> This is a paragraph </p>
<p id="dinosaur">This is a paragraph with a dinosaur.</p>
And the css file contains these properties:
p {border-style:dotted;}
p#dinosaur {border-style:solid; border-color:green}
Why does the second paragraph have a dotted border but is green?
Answer: The C in CSS stands for Cascading.
[HELP] Single questions & Help Thread [n00b]
http://4-ch.net/code/kareha.pl/1209513777/l50
btw, no need to ever put anything in front of a #thing because there can be only one #thing.
I thought that restriction was that HTML documents could not contain repeated IDs--does it apply to CSS as well? Not that I would ever do so, but I could have p#thing
and ul#thing
in the same style sheet, linked to multiple HTML documents, only using one rule or the other in each.
that's a possibility i hadn't thought about. i think your scenario would be fine. that's probably why it's allowed in the grammar. i stand corrected. thanks.
It is restricted on only HTML. in CSS #thing can appear no matter how many times you want it to.
You can't have a p#thing
and a ul#thing
but for a different reason- you can't change the tag of an element after it's created so one of them simply doesn't make sense. Some people take advantage of this when sharing a css file across multiple pages with different physical layouts on different pages.