views:

74

answers:

3

Hi,

Which advantages have definition list (<dd><dt> etc..) and when we should use it? (Example: use in Zend_Form, but i dont understand why)

Does exist other better options?

(I beginner, but its look to me that is xml use inside html. If I right XML not wide used recently because yaml, file.ini, json each of them in their field more efficient in parsing then xml format.)

Thanks

+5  A: 

Hi Yosef - this article might be useful to you.

http://www.benmeadowcroft.com/webdev/articles/definition-lists.shtml

Marko
+2  A: 

In HTML, <dl/> must be used each time you need a list of words with definitions. In practice, definition list is used in the situations where a simple list (unordered <ul/> or ordered <ol/>) is not enough.

For example, you want to display a list of files to download. Each file has an icon, a name, a size and a download button.

  1. First, you can put everything in a <table/>. That's what was done ten years before, when CSS was not used as intensively as today, and when the separation between content and presentation was not too clear.

  2. Then, you can just put everything in <div/>s: each file in a <div/>, each file name in a <div/>, etc. The problem is that the code will be longer, less easy to understand and more difficult to maintain.

  3. Then, you may want to put a <ul/> with plenty of <div/>s inside. This is similar to the (2.)

  4. Finally, you can use a definition list. The advantages will be a reduced size of HTML code and a code easier to maintain. By the way, accessibility will be increased: with CSS disabled, your page will still be readable (whereas with embedded <div/>s, the user will have much pain to understand that it is a list of files).

MainMa
Your use case is perfect for a table, not a definition/description list.
Alohci
@Alohci: not really. It would be purely a table for layout, and by the way, will hurt maintenance. For example, you have to display an icon on the left side, a name at the middle, than a size *below* the name, and a button on the right? Now, requirements change, and the button must be displayed below. With a table, you will need to change HTML, even if the requirement change is purely about layout.
MainMa
@MainMa - You're justifying the choice of semantic element based on the presentational requirements. Semantically, it's clearly a table - you have columns (icon, name, size, download link) and rows (the list of files). The <th>s are easy to identify and a caption or summary describing what the table does for the user is clear. Now, I agree that restyling a table in CSS alone is extremely difficult. That's essentially a failure of CSS though, and not a justification for the incorrect choice of semantic element.
Alohci
@Alohci - Ok, I see and I agree with you.
MainMa
+2  A: 
Lèse majesté