[thelist] CSS - label tag - SOLVED?

Justin @ pxLabs justin at pxlabs.com
Sun Feb 13 16:20:23 CST 2005


Chris,

I think I've got it. I must say, the strict doctype is quite picky. I 
was out for a walk this afternoon, and I thought about converting my 
company's existing to strict, and as much as work it would be, I think 
that maybe it's a good idea.

After a fair amount of coding, thinking, more coding, and chain-smoking 
my way towards a solution, here is the code that validates against the 
Strict doctype.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">

label,input {
    display: block;
    width: 150px;
    float: left;
    margin-bottom: 10px;
}

label {
    text-align: left;
    width: 125px;
}

br {
    clear: left;
}
</style>
<title>Untitled Document</title>
</head>

<body>
<form action="">
<fieldset>
<legend>Form</legend>
    <label for="Field1">Field 1</label>
    <input id="Field1" name="Field1" /><br />

    <label for="Field2345">Field 2345</label>
    <input id="Field2345" name="Field2345" /><br />

    <label for="Field34567890">Field 34567890</label>
    <input id="Field34567890" name="Field34567890" />
</fieldset>
</form>
</body>
</html>

Of course adjust the colors, widths, fonts and so on to your/your 
client's liking.

Enjoy!

Justin Kozuch
Creative Director, pxLabs
"Helping clients improve their business through the use of Web standards"
www.pxlabs.com



More information about the thelist mailing list