1

I have been learning Jekyll which uses Kramdown as a HTML preprocessor.

What I can't seem to work out is how to assign elements an id.

In Kramdown to created an Ordered List you just use

1. 
2. 

but how on earth do I assign this element an Id for CSS or for linking to?

So e.g.

<ul id="list">
  <li id="1">1</li>

I tried tried

1. item {#}
matt
  • 78,533
  • 8
  • 163
  • 197
Alan Auckland
  • 115
  • 2
  • 10

2 Answers2

4

You can apply IDs and classes when using kramdown, yeah!

This is a paragraph
{: #my_id .my_class}


# This is an h1 header  {: #my_id}

View more cool stuff you can do with kramdown here on this article

Hope to have helped! :)

Virtua Creative
  • 2,025
  • 1
  • 13
  • 18
  • I've never tried to apply them for lists, but I'm pretty sure it can be done with markdown markup. On the article you'll see the link for the official reference. But if it doesn't work for lists, you can simply add the list as HTML markup. – Virtua Creative Mar 11 '16 at 21:55
  • I have this to created links to each id '[1](#1), [2](#2), [3](#3), [4](#4), [5](#5), [6](#6), [7](#7), [8](#8) SO I have a paragraph which I want to assign the id="1" 'Click the **FILE** tab, then click **New** {: #1 .class}' The class applied to the

    but there was still no ID.

    – Alan Auckland Mar 12 '16 at 00:02
2

To add an id attribute on the li element, place the inline attribute list immediately after the list marker (i.e. the number and period). Note there must be a space after the ..

For example this kramdown:

1. {: #id-for-item-1 } List Item 1   
2. {: #id-for-item-2 } List Item 2

produces this HTML:

<ol>
  <li id="id-for-item-1">List Item 1</li>
  <li id="id-for-item-2">List Item 2</li>
</ol>

Also note you need the colon (:) in the IAL.

matt
  • 78,533
  • 8
  • 163
  • 197