# Feature request: automatically generated ids for headers

**URL:** <https://talk.commonmark.org/t/feature-request-automatically-generated-ids-for-headers/115>\
**Category:** Uncategorized\
**Created:** [September 3, 2014, 9:49pm UTC](https://talk.commonmark.org/t/feature-request-automatically-generated-ids-for-headers/115 "2014-09-03T21:49:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![zwol](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/zwol/32/63_2.png) [@zwol](https://talk.commonmark.org/u/zwol)\
**Post date:** [September 3, 2014, 9:49pm UTC](https://talk.commonmark.org/t/feature-request-automatically-generated-ids-for-headers/115/1 "2014-09-03T21:49:39Z")

</div>

One of the big lacunae in Markdown (IMNSHO) is that there’s no way to get `id=""` attributes in the generated HTML, and therefore, no way to use fragment references when linking to the containing document.

A _general_ mechanism for adding id attributes to generated HTML elements seems Too Hard, and any mechanism for adding _user-specified_ attributes to generated elements is going to have backward compatibility headaches. However, id attributes are most useful on headers, and it’s possible to generate id attributes algorithmically from the header text, so I’d like to propose that Markdown should do that. A reasonable algorithm might look something like

1. Apply aggressive Unicode normalization (NFKC + lowercasing) to the text of the header.
2. Replace all characters not in Unicode categories [L\*] and [N\*] (that is, that are neither letters nor numbers) with `-` characters.
3. Compress all runs of `-` characters to a single `-`.

I’m sure this can be bikeshedded, but the important thing is to get implementations consistently doing _something_, not the exact details.

---

_[View the full topic](https://talk.commonmark.org/t/feature-request-automatically-generated-ids-for-headers/115)._
