I've come across a few examples recently that do things like:
<dl> <dt>Full Name:</dt> <dd><input type="text" name="fullname"></dd> <dt>Email Address:</dt> <dd><input type="text" name="email"></dd> </dl>
for doing HTML forms. Why is that? What is the advantage over using tables?
1. HTML definition list represents a term and a relevant description in the form of the list. 2. HTML definition list starts and ends with dl element (i.e. <dl> and </dl>).
The HTML5 dl, dt and dd tags used to list data. The <dl> tag is used to specify (start) the definition list. This tag is commonly used to implement a glossary.
The <dd> tag is used to describe a term/name in a description list. The <dd> tag is used in conjunction with <dl> (defines a description list) and <dt> (defines terms/names). Inside a <dd> tag you can put paragraphs, line breaks, images, links, lists, etc.
The <dl> HTML element represents a description list. The element encloses a list of groups of terms (specified using the <dt> element) and descriptions (provided by <dd> elements).
I guess it's up to you to determine the semantics, but in my opinion:
Rather than a definition list, form-related properties should be used.
<form> <label for="fullname">Full Name:</label> <input type="text" name="fullname" id="fullname"> <label for="email">Email Address:</label> <input type="text" name="email" id="email"> </form>
The "for" attribute in the <label> tag should reference the "id" attribute of a <input> tag. Note that when labels are associated with fields, clicking the label will put the associated field in focus.
You can also use tags like <fieldset> to cluster sections of a form together and <legend> to caption a fieldset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With