<div class="horizontal_bar" style="width:100px"></div>
.horizontal_bar{
height: 13px;
background-color: red;
}
If I do that, I get a red bar that's 100 pixels wide and 13 pixels high. But I want to add a label to the left of the div, so I've made it inline, like this:
display: inline;
For some reason, this overrides the 100 pixel width I specified and makes it so that the width of the div is equal to the width of the contained elements, not 100 pixels. That is to say, if I have a div that I've set to 100px and it has a single 5 pixel wide asterisk in it, the resulting width of the div is 5 pixels. If there's nothing in the div, it doesn't show up at all.
This is the reason I hate CSS. If I could just fix this problem, then all my frustrations would be gone and my relationship with this particular markup language would be much more positive. Can anyone help me on this?
EDIT: I'm aware that it's bad practice to use inline styles. That's not the issue, so please don't bring it up.


Sign In
Create Account


Back to top









