The HTML5 <code>
element has an optional class="language-" attribute to define the language of the code fragment. An example from the spec:
<pre><code class="language-pascal">var i: Integer;
begin
i := 1;
end.</code></pre>
Is there a list of the languages to be used? Just thinking that otherwise there are likely to be multiple different spellings or interpretations of languages e.g. VB6 vs visual basic 6 etc.
In the WHATWG’s HTML Living Standard version of the specification, it does actually recommend prefixing the value of class
attributes on <code>
elements with "language-*
":
From the HTML Living Standard: Text-Level Semantics - the code element
There is no formal way to indicate the language of computer code being marked up. Authors who wish to mark code elements with the language used, e.g. so that syntax highlighting scripts can use the right rules, can use the class attribute, e.g. by adding a class prefixed with "language-" to the element.
(However, I would assume that this prefix has no real practical value – that would depend on whether real-world websites take up the convention and whether third-party tools detect and actually implement this prefix.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With