Reputation: 15491
I am developing a form and setting a size for the label and aligning it right so as to look decent. However the CSS is not getting applied. Here is my code:
label{
width: 50%;
text-align: right;
}
How do I get this working?
Upvotes: 3
Views: 1249
Reputation: 1894
fiddle : http://jsfiddle.net/46xF5/7/
change the css code like this
body{
font-family: "Arial", Helvetica, sans-serif;
}
/*changes here*/
#book_tickets label{
width: 50%;
display:inline-block;
text-align: left;
}
Upvotes: 1
Reputation: 8981
LIke this
css
label{
width:50%;
text-align: right;
border:1px solid red;
display:inline-block;
}
Upvotes: 1
Reputation: 240878
You could make it an inline-block
element:
label{
width: 50%;
text-align: right;
display:inline-block;
}
You need to do this because a label
is an inline
element, and the following applies to it:
10 Visual formatting model details - 10.2 Content width: the 'width' property
This [width] property does not apply to non-replaced inline elements. The content width of a non-replaced inline element's boxes is that of the rendered content within them (before any relative offset of children). Recall that inline boxes flow into line boxes. The width of line boxes is given by the their containing block, but may be shorted by the presence of floats
Upvotes: 2