Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I render a DT on the same line as its DD?

Tags:

html

css

I'm looking for a list of definitions that are inline with their terms, so that

<dl>
  <dt>Email</dt><dd>[email protected]</dd>
  <dt>Bio</dt><dd>Person's full-text bio, which spans multiple lines, and starts on the same line as the text <q>Bio</q>, just like the previous definitions. Any given solution should both allow this text to wrap below the &lt;dd&gt; and then provide a line break afterwards.</dd>
  <dt>Phone</dt><dd>(555) 123-4567</dd>
</dl>

Renders as:

Email: [email protected]

Bio: Person's full-text bio, which spans multiple lines, and starts on the same line as the text “Bio”, just like the previous definitions. Any given solution should both allow this text to wrap below the <dd> and then provide a line break afterwards.

Phone: (555) 123-4567

I've already tried using dt,dd{display:inline}, but that caused all definitions to be displayed on one line with eachother.

I've already reviewed How to style dt and dd so they are on the same line? and it resulted in a more tabular layout, which won't work in this case.

like image 416
Ky. Avatar asked Apr 18 '13 14:04

Ky.


People also ask

How do you style DT and DD so on the same line?

This can be accomplished by adding a DIV element with the CSS overflow: hidden; around the content of the DD tag. You can omit this extra DIV , but the content of the DD tag will wrap under the floated DT .

What is the difference between DT and DD?

The <dt> tag is used to specify the description list. The <dd> tag stands for definition description and used to denote the description or definition of an item in a description list. The <dl> tag is used to represent the description list. This tag is used with <dt> and <dd> tags.

What is DT DD DL in HTML?

Definition and UsageThe <dd> tag is used to describe a term/name in a description list. The <dd> tag is used in conjunction with <dl> (defines a description list) and <dt> (defines terms/names). Inside a <dd> tag you can put paragraphs, line breaks, images, links, lists, etc.


1 Answers

Ok this works just the way you wanted. I fixed wazaminator code so that it works across browsers. The problem was that a few browsers add a margin-start for dds. I didn't test in IE:

dt {
  float: left;
  clear: left;
  margin-right: 5px;
  font-weight: bold;
}

dd {
  margin-left: 0px;
}

http://jsfiddle.net/sPQmw/18/

like image 58
vlasits Avatar answered Oct 21 '22 03:10

vlasits