# Fenced code blocks should add class to \`code\` rather than \`pre\`, matching the HTML best practice

**URL:** <https://talk.commonmark.org/t/fenced-code-blocks-should-add-class-to-code-rather-than-pre-matching-the-html-best-practice/136>\
**Category:** Spec\
**Created:** [September 3, 2014, 11:09pm UTC](https://talk.commonmark.org/t/fenced-code-blocks-should-add-class-to-code-rather-than-pre-matching-the-html-best-practice/136 "2014-09-03T23:09:22Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![rokejulianlockhart](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/rokejulianlockhart/32/3399_2.png) [@rokejulianlockhart](https://talk.commonmark.org/u/rokejulianlockhart)\
**Post date:** [May 22, 2026, 4:26pm UTC](https://talk.commonmark.org/t/fenced-code-blocks-should-add-class-to-code-rather-than-pre-matching-the-html-best-practice/136/8 "2026-05-22T16:26:54Z")

</div>

@mathias, isn’t the best practice to utilise both, like `<pre><code lang="mul" class="language-javaScript">`? The WHATWG’s HTML5 LS and IETF’s BCP 47 appear to recommend this (with `type="text/x.javaScript"` also appended, in `script`s).

---

_[View the full topic](https://talk.commonmark.org/t/fenced-code-blocks-should-add-class-to-code-rather-than-pre-matching-the-html-best-practice/136)._
