user16667996
user16667996

Reputation: 11

why does this simple css code cause all div elements in body to turn red?

<body>
    <div class="child-one">one<div>
    <div class="child-two">two</div>
    <div class="child-three">three</div>
</body>

body {
background-color: yellow;
font-family: 'Courier New', Courier, monospace;
}
.child-one {
background-color: rgb(206, 41, 41);
position: relative;
left: 20px;
}
.child-two {
background-color: white;
}
.child-three {
background-color: green;
}

On chrome, all three div elements are red but I cannot seem to find out why they are same color?

Upvotes: 0

Views: 156

Answers (1)

MeDead
MeDead

Reputation: 197

You forgot the / in your ending tag

<body>
    <div class="child-one">one<div> to </div> <------
    <div class="child-two">two</div>
    <div class="child-three">three</div>
</body>

body {
background-color: yellow;
font-family: 'Courier New', Courier, monospace;
}
.child-one {
background-color: rgb(206, 41, 41);
position: relative;
left: 20px;
}
.child-two {
background-color: white;
}
.child-three {
background-color: green;
}
<body>
    <div class="child-one">one</div>
    <div class="child-two">two</div>
    <div class="child-three">three</div>
</body>

Upvotes: 1

Related Questions