简体   繁体   中英

CSS Selector not working on elements within a div

I have the following HTML structure:

<div class="formFields">
     <label> Field 1: </label>
     <input type="text" value="" name="field1" />
</div>

And my CSS selectors are as follows:

#formFields {clear:both;}
#formFields label {font-weight:bold;}

The clear:both; is being applied to the div, but the font-weight:bold; is not being applied to the labels. How would I apply this font-weight to the labels?

At the moment, none of the rules is being applied to the div.

  • # is the ID selector

  • . would be the class selector

so you'll either have to give the rules the class selector

.formFields

or give the div the ID formFields :

<div id="formFields">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM