Why width CSS attribute of label doesn't work without float?
I'm new in CSS, and I've got one question. I'd like to make a good simple
form, and there is the following code:
<form>
<div class="row"><label for="name">Some text field</label><input
type="text" name="name" /></div>
<div class="row"><label for="surname">Some another text
field</label><input type="text" name="surname" /></div>
</form>
Some CSS code:
label {
float: left;
width: 230px;
text-align: right;
margin: 5px;
}
.row {
clear: left;
}
I copied and pasted this code from some book. I understand floating,
clearing, but I don't understand why does "width" attribute work with
label (because it inline element) and, in this case, why doesn't "width"
work without "float"? Please, make me clear. Thanks
No comments:
Post a Comment