简体   繁体   中英

Why doesn't css work with this div?

So I have a body here:

 <body>
 <div id=”first”>
    <span class=”red”>This is a DIV Container</span>

    Or
    <br>
    This
</div>

And I have a style sheet with this

#first{
    background-color:red;
}

But the background color doesn't change. I have no idea what I'm doing wrong...

Here's a jsfiddle with the code

https://jsfiddle.net/fuz5uqfb/

Doesn't worth there either.

You're using the wrong kind of quotation marks for your div id and span class . It should be this:

<body>
    <div id="first">
        <span class="red">This is a DIV Container</span>

        Or
        <br>
        This
    </div>
</body>

Updated Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM