开发者

dl, dt. dd for multiple list data

开发者 https://www.devze.com 2023-02-19 20:37 出处:网络
As from the tutorial here, I can see that this is a valid markup dl, dt, dd structure, <dl> <dt>Name: </dt>

As from the tutorial here, I can see that this is a valid markup dl, dt, dd structure,

<dl>
    <dt>Name: </dt>
    <dd>John Don</dd>

    <dt>Age: </dt>
    <dd>23</dd>

    <dt>Gender: </dt>
    <dd>Male</dd>

    <dt>Day of Birth:</dt>
    <dd>12th M开发者_StackOverfloway 1986</dd>
</dl>

but this only structure for a single person, what about multiple people/ persons? What about this below? I want to have a header and then followed by a list of items,

<dl class="name-header">
    <dt>Name: </dt>
    <dt>Age: </dt> 
    <dt>Gender: </dt> 
    <dt>Day of Birth:</dt>
</dl>

<dl class="person-item">
    <dd>John Don</dd>
    <dd>23</dd>
    <dd>Male</dd>
    <dd>12th May 1986</dd>
</dl>

<dl class="person-item">
    <dd>John Don</dd>
    <dd>23</dd>
    <dd>Male</dd>
    <dd>12th May 1986</dd>
</dl>

Thanks.

EDIT:

dl, dt. dd for multiple list data


Consider a table:

<table>
    <tr>
        <th>Name:</th>
        <th>Age:</th>
        <th>Gender:</th>
    </tr>
    <tr>
        <td>John Don</td>
        <td>23</td>
        <td>Male</td>
    </tr>
    <tr>
        <td>John Don II</td>
        <td>53</td>
        <td>Male</td>
    </tr>
</table>


In my opinion, using the tages the way you have BREAKS the semantic meaning.

With the markup below, it's obvious that 23 refers to the subject's age:

<dl>
   <dt>Name:</dt>
   <dd>John Don</dd>

   <dt>Age:</dt>
   <dd>23</dd>

   <dt>Birth Date:</dt>
   <dd>May 24 1967</dd>
</dl>

With your markup, it really isn't easy to tell:

<dl class="name-header">      
  <dt>Name: </dt>      
  <dt>Age: </dt>       
  <dt>Gender: </dt>       
  <dt>Day of Birth:</dt>      
</dl>          

<dl class="person-item">      
  <dd>John Don</dd>      
  <dd>23</dd>      
  <dd>Male</dd>      
  <dd>12th May 1986</dd>      
</dl>      

<dl class="person-item">      
   <dd>John Don</dd>      
   <dd>23</dd>      
   <dd>Male</dd>      
   <dd>12th May 1986</dd>      
</dl>


The one below seems to be valid according to the spec, since neither a dd nor a dt is mandated; nevertheless I second the table proposal, as you will have less trouble keeping the headers and the content together.

0

精彩评论

暂无评论...
验证码 换一张
取 消