maya sophie5,754 Points
about div and how did appeared here
I don't see any div in the html code.....where did div came from? I checked css properties and I see a #color div but how div get attached to html code???? the body is the div? or ??? thx
Robbie Thomas31,092 Points
If it answers your question, the "#" in color is an ID.
Hopefully, I'm making sense here, if not, I'd imagine someone else better than me will comment below.
Tom StringerPro Student 1,709 Points
As Robbie alluded to above - the
# you see in the CSS is a selector
In this case, the hash (#) is used to select HTML entities that have an ID matching that value, so in this case
#color that we see in the CSS is saying "Select any entity that has the ID of 'color' in the HTML and apply the following styles".
Furthermore in the CSS the full rule is actually
#color div. This is "scoped" more specifically to select any
<div> element within an element that has an ID of "color".
So it would pick up/match
<div id="color"> <!-- Doesn't match this -->
<div>Matches on me!</div>
</div> <!-- Also doesn't match on me -->
But wouldn't match
In this way CSS can be used to target very specific things, or very broad-ranges of items. It also makes more sense with the naming as it is called "Cascading Style Sheets" Because as you get more specific with the selectors, they will overwrite more "broad" selectors that have already been written.
<body> of the HTML, which means the script that they write is being run (and the HTML is then being generated in a loop) in the body of the HTML.
This wouldn't work if placed in the <head> of the document (reserved for metadata)
I suggest doing a quick course on CSS to get familiar with the scoping and possibilities!