tags:

views:

43

answers:

2

I have a <dl> and I would like to add a header to it.

My first attempt is not successful - I don't know how to get the <dt> header to span both the subsequent <dt> and <dd> elements.

<style>
dl.table-display{
    float: left; width: 100%;
    margin: 1em 0;
    padding: 0;
    font-family: verdana,arial,helvetica,sans-serif; 
    font-size: 13px; 
    line-height: 20px;
}
dt.list_header  {
    text-align: center; 
    color: white; 
    width:100%; 
    background-color: #3061B7;
}
.table-display dt{
    clear: left;
    float: left;
    width: 50px;
    margin: 0;
    padding: 5px;
}
.table-display dd{
    float: left;
    width: 50%;
    margin: 0;
    padding: 5px;
}
</style>
<dl class="table-display">
    <dt class="list_header">Header</dt>
    <dt>Name</dt>
    <dd>Title</dd>
    <dt>Name</dt>
    <dd>Title</dd>
    <dt>Name</dt>
    <dd>Title</dd>
    <dt>Name</dt>
    <dd>Title</dd>
</dl>
+1  A: 

http://w3.org/TR/html401/struct/global.html#h-7.5.5

(also, FFR, doctype declarations are important [AKA valid code is important])

reisio
what's the problem with my markup? are you complaining because I only gave you the dl and the style?
Nathan DeWitt
I'm mentioning that you will likely have problems in the future if you don't use valid markup.
reisio
do you add that to all your HTML questions, or did you have a specific problem with mine because I didn't include the full html page?
Nathan DeWitt
No; I don't have a problem — you have (in that your code has). I thought I'd let you know, because friends don't let friends waste time debugging CSS in quirks mode.
reisio
i just posted the relevant snippet: the `dl` tag and the `style` info. i am fully aware that this was not a full html page. do you also tell people their code won't compile when they only post a snippet?
Nathan DeWitt
Apples and oranges. Linking to a live example that doesn't have a doctype declaration and asking for how to accomplish a particular rendering via CSS is indicative of not realizing how important doctype declarations are to CSS rendering. Ask anyone.
reisio
+2  A: 

Why not just put an <h2> or <h3> tag above the <dl>? It would be more semantically correct.

Jim Lamb