0

I've got this html:

<label class="fixedwidthlbl" for="city">City</label>
<input type="text" name="city" id="city">
<br/>
<label class="fixedwidthlbl" for="state">State</label>
<input type="text" name="state" id="state">
<br/>
<label class="fixedwidthlbl" for="yearin">Year Arrived</label>
<input type="text" name="yearin" id="yearin">
<br/>
<label class="fixedwidthlbl" for="yearout">Year Departed</label>
<input type="text" name="yearout" id="yearout">
<br/>
<input type="submit" name="insertdocument" id="insertdocument" value="Add Place Lived">

...and this CSS:

.fixedwidthlbl {
    width: 320px;
    padding: 2 px;  
}

Yet the "fixedwidthlbl" class is having no effect on my labels.

I've got a fiddle here.

What is wrong with my HTML and/or CSS?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

1 Answers1

4

label are inline elements. To give them a width you will need to give them display: inline-block;

.fixedwidthlbl {
    width: 320px;
    padding: 2px;   
    display: inline-block;
}
somethinghere
  • 16,311
  • 2
  • 28
  • 42
Zimmi
  • 1,599
  • 1
  • 10
  • 14