Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: <DL> with spacing/margin between the dt/dd pairs

Tags:

css

I have the following html:

<dl>
        <dt>Item 1</dt>
        <dd>
            <ul>
                <li>Value 1</li>
            </ul>
        </dd>
        <dt>Item 2</dt>
        <dd>
            <!-- this item is missing a value -->
        </dd>
        <dt>Item 3</dt>
        <dd>
            <ul>
                <li>Value 1</li>
                <li>Value 2</li>
                <li>Value 3</li>
            </ul>
        </dd>
    </dl>

I would like to lay it out like (instead of the normal dl which puts the term and definitions under each other):

Item 1    Value 1
Item 2    
Item 3    Value 1
          Value 2
          Value 3

Which is not a problem. The problem is that I would like to add a margin between each term/definition pair. The problem is that the definitions are not the same height (they range between 0 up to 5 list items), so I cannot apply the same margin on the dd tags.

like image 584
Gideon Avatar asked May 22 '09 08:05

Gideon


People also ask

What is DT DD DL in HTML?

HTML <dd> TagThe <dd> tag in HTML is used along with <dl> tag which defines the description list and <dt> tag which defines the terms in the description list. The <dd> tag requires a starting, but the end tag is optional.

How do you put a space between CSS?

The CSS padding properties are used to generate space around an element's content, inside of any defined borders. With CSS, you have full control over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left).

What is the difference between DL and DT?

The <dl> tag is used to specify (start) the definition list. This tag is commonly used to implement a glossary. You can put only <dt> and <dd> tags inside the <dl> tag. The <dt> tag is used to specify the definition terms or items in a definition list.


1 Answers

How's this?

dt, dd { display: block; float: left; margin-top: 20px; }
dt { clear: both; }
like image 145
Rytmis Avatar answered Sep 22 '22 15:09

Rytmis