Reputation: 503
<div class="main" style="height: 10px;width: 280px;background:#F00;margin-left:20px;float:left;">
<div class="sub" style="clear: both;width: 80%;height: 10px;color: #00F;position: relative;top: 0px;left: 0px;"></div>
</div>
.main div is red
.sub div is blue
I can only see red, Why this is like a child's problem but I just can't work It out!
here are NO css style sheets
Upvotes: 0
Views: 2344
Reputation: 952
Your second div cannot be seen because you have set no color for it whatsoever.
You used the color: #00F;
property which changes the font color of an element. Instead you should have used the background-color
property on your second div which would have changed it's background color, aka the div's color.
Also try to use external CSS files as it is easier to spot mistakes and keep your work organised.
Upvotes: 0
Reputation: 4708
Your second div doesn't have a background color or any other thing that could make it show up, add a background color to the second div and you'll see its there.
While color:
changes the font color, background-color:
changes the color of the background.
also it's a good idea to use external css sheets or <style></style>
tags
Upvotes: 0