HTML5<code>
元素有一个可选的 class="language-" 属性 https://html.spec.whatwg.org/multipage/semantics.html#the-code-element定义代码片段的语言。规范中的一个示例:
<pre><code class="language-pascal">var i: Integer;
begin
i := 1;
end.</code></pre>
有要使用的语言列表吗?只是想否则可能会有多种不同的拼写或语言解释,例如VB6 与 Visual Basic 6 等
在 WHATWG 中HTML 生活标准 https://html.spec.whatwg.org/规范的版本,它实际上建议在值前面加上前缀class
属性上<code>
带有“的元素language-*
":
来自HTML 生活标准:文本级语义 - 代码元素 https://html.spec.whatwg.org/#the-code-element:classes
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.
(但是,我认为这个前缀没有真正的实用价值——这取决于现实世界的网站是否采用该约定以及第三方工具是否检测并实际实现这个前缀。)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)