Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an appropriate HTML pattern for displaying name/value pairs?

I was inspired to ask this by a comment on my How can I style a list of name-value pairs to appear like an HTML table? question last night, that code like this is not an appropriate use of label. What should I rather use to indicate a fixed-name / changing-value pair in read only mode?

<ol class="name-value" style="width: 100%;">
    <li>                    
        <label for="about">Client</label>
        <span id="about">Apartment Applied Visual Arts</span>
    </li>
    <li>
        <label for="about">Report Date</label>
        <span id="Span1">2011/08/08 16:50:10</span>
    </li>
    <li>
        <label for="about">Report No.</label>
        <span id="Span2">33251</span>
    </li>
</ol>
like image 334
ProfK Avatar asked Aug 09 '11 05:08

ProfK


People also ask

What are name value pairs in HTML?

Name-value pairs are represented by a set of text strings in which name="value" are usually separated by commas, semicolons, space or newline character.

What are name value pairs in a form?

A name–value pair, also called an attribute–value pair, key–value pair, or field–value pair, is a fundamental data representation in computing systems and applications. Designers often desire an open-ended data structure that allows for future extension without modifying existing code or data.

What is key and value in HTML?

The key-value pair idea is used by CSS rules to set values of properties, so you can paint a particular style for HTML elements, see the next css rule which targets a elements. a { color: crimson; font-size: 1.5em; }


1 Answers

I use definition lists:

<dl>
    <dt>Key</dt>
    <dd>Value</dd>
    <dt>Another key</dt>
    <dd>Another value</dd>
</dl>
like image 194
icktoofay Avatar answered Oct 20 '22 16:10

icktoofay