88

I just wrote this question and was wondering if there's a MarkdownSharp syntax for specifying a definition list -- it would have made specifying those function arguments a bit more natural...

If there's not, no big deal :)

  • 1
    +1. I just tried to use <dl> in a meta post and was surprised when it didn't work. – finnw Jun 17 '12 at 23:10
  • 3
    Its actually called description list since HTML5 w3.org – adius Jul 10 '13 at 18:48
-28

Yes, with <dl> and <dd> definition lists.

The tags can be used since it is allowed to use HTML in Markdown.

Example

<dl>
  <dt><strong>Lower cost</strong></dt>
  <dd>The new version of this product costs significantly less than the previous one!</dd>
  <dt><strong>Easier to use</strong></dt>
  <dd>We've changed the product so that it's much easier to use!</dd>
  <dt><strong>Safe for kids</strong></dt>
  <dd>You can leave your kids alone in a room with this product and they
      won't get hurt (not a guarantee).</dd>
</dl>

Result:

Lower cost
The new version of this product costs significantly less than the previous one!
Easier to use
We've changed the product so that it's much easier to use!
Safe for kids
You can leave your kids alone in a room with this product and they won't get hurt (not a guarantee).
  • 3
    @billy I don't really like definitions, I think they're ultra-pointless. I guess our CSS doesn't contain the right styles.. shrug. – Jeff Atwood Dec 16 '10 at 5:27
  • 122
    What's pointless about definition lists? It seems fairly common to break down a topic in to parts, eg. "There are several ways to answer your question: <dt>Solution #1</dt><dd>Description of Solution #1</dd><dt>Solution #2..." I'm not particular about using dl/dd/dt specifically, but the "list of things with further definition" is a useful construct to have; is there a better way of generating these in your opinion? (maybe using lists where every other term is bolded or something?) – machineghost Aug 29 '12 at 18:55
  • 71
    How can you claim they're useless when the OP obviously has a use for them? How else would you notate a definition list without the definition list syntax? Nested lists with bolded terms are not the same thing. – endolith Sep 17 '12 at 14:51
  • 8
    I like definition lists. I manage a lot of pro wrestling and MMA websites, and they’re good for displaying fighters’ stats, i.e. height, weight, win/loss record etc. They’re not totally useless, that’s just your opinion. They wouldn’t be available in HTML if they were totally useless. – Martin Bean Nov 16 '12 at 11:00
  • 12
    Well defined terms in well structured document are base of good and focused text. Without them the text can easily become pointless. – Jan Vlcinsky Dec 8 '12 at 15:19
  • 1
    @MartinBean Definition lists are useful for glossaries and the like. For your case, the semantically proper element is <table>. – Marnen Laibow-Koser Mar 6 '13 at 22:56
  • 1
    @MarnenLaibow-Koser it depends on whether the page is listing more than one wrestler. For a listing of wrestlers I'd agree a table is better, but if it's just one page listing the stats for these wrestlers a definition list is probably more apt. Otherwise you basically have a table that is either 2 rows (with one row being the fields) or 2 columns (with on column being the fields). – Jordan Reiter Mar 8 '13 at 18:35
  • 2
    I guess I always felt like tables are most useful when looking at more than one record. I just don't see it as that useful when all you have really is name-value pairs. – Jordan Reiter Mar 12 '13 at 1:43
  • 3
    @MarnenLaibow-Koser A table with only 2 columns is just sad. So is a "table" with only 1 row. If you think about it, you cannot imagine someone writing a document, then taking a ruler to make a table with 2 colums or 2 rows. I have seen in (old) books, huge tables with lots of white space that has two columns. They don't look aesthetic. Furthermore, the use of <dl> helps the browser to know that the <dd> contains the further explanation for the <dt>. A table does not do this. Think screen readers. Etc. – andho Jun 27 '13 at 10:03
  • 37
    Definition lists are incredibly useful and it's unfortunate how underused they are, as this neglect has resulted in lack of attention and improvement in HTML5. They can be used wherever a field-value pair is used, like forms and database record output. Instead, these situations are often justified as "tabular" to use tables for layout. Mostly because people who don't put thought into semantic markup and are satisfied with using 4 divs to wrap one element call them useless and sad. – Anthony Aug 1 '13 at 9:33
  • 5
    even if the question is old just want to say that definition lists are actually important for the semantic web. So a good thing for SEO. – qudrat Sep 19 '13 at 14:38
  • 7
    Sorry, but what a useless answer. Definition lists are tremendously useful. – tobibeer Feb 5 '15 at 13:17
  • 4
    This answer is very crass. I'm surprised the question owner selected it as the best answer. Maybe it was the only one at the time. As of now, this answer has -13 votes. This is the first time I've seen a "best answer" with a negative number of votes. – L S Nov 22 '16 at 19:25
  • 3
    They make perfect sense (and complement <ul> and <ol>) if you think of them as "named lists". – naught101 Feb 8 '17 at 6:17
  • 5
    This answer is marked "correct" because writing your definition list with HTML is the only cross-implementation standard method of doing this in Markdown. The fact that basic Markdown syntax does not include this is a hole in the spec in my opinion. It's also voted down for (I'm guessing) patronizing the OP. Which definitely detracts from the usefulness of this answer. – meustrus Sep 21 '17 at 16:40
66

Maruku and kramdown support this.

kramdown
: A Markdown-superset converter

It looks like it doesn’t work on Stack Overflow though.

§ Definition Lists

19

Markdown doesn't support description lists, however you can mimic this feature by placing two spaces at the end of a line to insert a line break, and then have to start description on the very next line

For example

1. Ist Item  
First item with having index value 1
1. 2nd Item  
Second item having index value 2, beside we gave it 1, which indicates that markdown parser does not break the list.
1. **3rd Item:**  
&nbsp;&nbsp;&nbsp;&nbsp;If you want to do something fancy with your list

The above code will produce following results

  1. 1st Item
    First item with having index value 1
  2. 2nd Item
    Second item having index value 2, beside we gave it 1, which indicates that markdown parser does not break the list.
  3. 3rd Item:
        If you want to do something fancy with your list
  • 3
    This for sure mimics a definition list but is in the rendered HTML an <ol> container with <li> items where the first line and the next are separated with a <br> caused by the double space. So although not what the OP asks for, still a good workaround. – rene Jul 27 '17 at 6:01
  • 1
    If you are writing pure Markdown (no HTML allowed), and don't have Kramdown or other extensions to support definition lists, "mimicking" a definition list using a bulleted list with bold or italic terms followed by hard line breaks is probably the best you can do. Thanks for the suggestion. – Alex Dupuy Oct 13 '17 at 16:20
  • If your Markdown processor (e.g. GFM) supports it, using a trailing backslash instead of two trailing spaces may be preferable. – Alex Dupuy Oct 13 '17 at 17:23
  • 1
    This answer is helpful so I won't downvote it, but it is not entirely correct so I'll edit it. – Domino Oct 25 '18 at 2:10
  • I didn't know about the two spaces trick. Thanks! – einpoklum - reinstate Monica Oct 5 at 14:28
-1

This is not the answer, but if you found this question, like me, while trying to solve the problem with GitHub flavored Markdown then you may find this of some use...

For GitHub Markdown you can use a series of blockquotes and paragraphs like this:

>  Item 1

Describe Item 1

>  Item 2

Describe Item 2

How this looks depends on the theme your pages use. For example:

Item 1

Describe Item 1

Item 2

Describe Item 2

As Elin commented below, this does not work for accessibility (screen readers) or semantically.

  • While it might not be obvious from the question, it is specifically about the markdown flavor used by SE, which is certainly close to that of Github's flavor but isn't a 100% match. And this still mimics the effect, it doesn't generate a <dl> and <dd> tag which is what the OP is really asking for. – rene Oct 5 at 13:27
  • Thanks rene. I understand. As you observed, I came to this question looking for help with Github and Vuepress markdown. Same problem. Same answer. I'm just offering a workaround that worked for me. – Bryan Oct 5 at 17:07
  • It does work visually, but not for a screen reader or semantically. It's so frustrating that they are not supported. – Elin Oct 5 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .