legend
elements with CSSThis demo page is related to the article Styling form controls with CSS, revisited. For more info on the purpose of this page, please read the article.
Each fieldset
element consists of this HTML:
<fieldset id="el##">
<legend>#el##</legend>
<p>Some text.</p>
</fieldset>
The following CSS rules are used to style the legend
elements:
fieldset {position:relative} /* For legend positioning */
#el01 legend {padding:0} /* Remove padding */
#el02 legend { /* Text and background colour, blue on light gray */
color:#00f;
background-color:#ddd;
}
#el03 legend {background:url(/i/icon-info.gif) no-repeat 100% 50%} /* Background image */
#el04 legend {margin:0} /* Remove margin */
#el05 legend {border:2px dotted #00f} /* Border width, style and colour */
#el06 legend { /* Position at top left corner of fieldset */
position:absolute;
top:0;
left:0;
}
#el07 legend {font-family:"Courier New",Courier} /* Different font */
#el08 legend {font-size:2em} /* Bigger text */
#el09 legend {font-size:0.5em} /* Smaller text */
#el10 legend {font-weight:bold} /* Bold text */
#el11 legend {padding:2em} /* Increase padding */
#el12 legend {text-align:right} /* Change text alignment */
In your current browser, with your current settings, the legend
elements look like this:
And here are screenshots from several browsers on different operating systems: