Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:05:48+00:00 2026-05-15T20:05:48+00:00

This is a question I have been struggling with for a while. What is

  • 0

This is a question I have been struggling with for a while. What is the proper way to mark up name/value pairs?

I’m fond of the <dl> element, but it presents a problem: There is no way to separate one pair from another – they have no unique container. Visually, the code lacks definition. Semantically, though, I think this is the correct markup.

<dl>
    <dt>Name</dt>
    <dd>Value</dd>
    <dt>Name</dt>
    <dd>Value</dd>
</dl>

In the above code, it is difficult to properly offset the pairs visually, both in code and rendered. If I wanted to, for instance, but a border around each pair, that would be a problem.

We may point to tables. It could be argued that name-value pairs are tabular data. That seems incorrect to me, but I see the argument. However, the HTML does not differentiate the name from the value, except in position, or with the addition of class names.

<table>
    <tr>
        <td>Name</td>
        <td>Value</td>
    </tr>
    <tr>
        <td>Name</td>
        <td>Value</td>
    </tr>
</table>

This makes much more sense from a visual standpoint, both in code and in CSS. Styling the aforementioned border is trivial. However, as mentioned above, the semantics are fuzzy at best.

Thoughts, comments, questions?

Edit/Update
Perhaps this was something I should have explicitly mentioned in relation to structure, but a definition list also has the problem of not semantically grouping the pairs. The ordering and implicit border between a dd and a dt is easily understood, but they still feel slightly off to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:05:48+00:00Added an answer on May 15, 2026 at 8:05 pm

    Thanks for this interesting question. There are few more things to consider here.

    What is a pair? Two elements together. So we need a tag for this.
    Let’s say it is pair tag.

     <pair></pair>
    

    The pair contains the key, and the corresponding value:

     <pair><key>keyname</key><value>value</value></pair>
    

    Then, we need to list the pairs:

    <pairlist>
         <pair><key>keyname</key><value>value</value></pair>
         <pair><key>keyname</key><value>value</value></pair>
    </pairlist>
    

    The next thing to consider, is the display of the pairs.
    The usual layout is the tabular one:

    key value
    key value
    

    and the optional separator, which is usually colon:

    key : value
    key : value
    

    The colons can be easily added via CSS, but this certainly won’t work in IE.

    Case described above is the ideal one. But there is no valid HTML markup to fit in this easily.


    To sum up:

    dl is semantically closest, for simple cases of key and value, but is hard to apply visual styles
    (eg. to display the pairs inline or to add red border to just hovered pair). The case which fits most for dl is glossary. But this is not the case we discuss.

    The only alternative I can see in this case is to use table, like this:

    <table summary="This are the key and value pairs">
        <caption>Some notes about semantics</caption>
        <thead class="aural if not needed">
            <tr><th scope="col">keys</th><th scope="col">values</th></tr>
        </thead>
        <tbody class="group1">  
            <tr><th scope="row">key1</th><td>value1</td></tr>
            <tr><th scope="row">key2</th><td>value2</td></tr>
        </tbody>
        <tbody class="group2">
            <tr><th scope="row">key3</th><td>value3</td></tr>
            <tr><th scope="row">key4</th><td>value4</td></tr>
        </tbody>
    </table>
    

    One more:

    <ul>
      <li><strong>key</strong> value</li>
      <li><strong>key</strong> value</li>
    </ul>
    

    or:

    <ul>
      <li><b>key</b> value</li>
      <li><b>key</b> value</li>
    </ul>
    

    or, when the keys may be linked:

    <ul>
      <li><a href="/key1">key1</a> value</li>
      <li><a href="/key2">key1</a> value</li>
    </ul>
    

    The key and value pairs are usually stored in database, and those usually store tabular data,
    so the table would fit best IMHO.

    What do you think?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem like a very simple question, but I have been struggling with
This question has been asked before ( link ) but I have slightly different
This might be too opinionated a question, but looking for help! I have been
Okay, I know this question have been asked plenty of times already, but I
This question may have been asked before, but I couldn't find an answer to
I know this question must have been covered endless of times, but I've searched
I have been asking myself this question for a long time now. Thought of
This is a (hopefully) really simple question - I have been told recently that
This may be a bit of a nooby question, I have been trying to
Similar questions to this one have been asked but none seem to address my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.