Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use definition lists (DL,DD,DT) tags for HTML forms instead of tables?

Tags:

html

css

forms

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?

like image 846
cletus Avatar asked Feb 06 '09 05:02

cletus


People also ask

Why do we use definition list in HTML?

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>).

What is the use of DL DT DD in HTML?

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.

What is the use of DT & DD tags in definition list give HTML example?

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.

What is the use of DL tag in HTML?

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).


1 Answers

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.

like image 71
sjstrutt Avatar answered Sep 20 '22 06:09

sjstrutt