2

I saw in this post How can I show code (specifically C++) in an HTML page? an example of how to use HTML5's code tags to format Pascal code:

<pre><code class="language-pascal">var i: Integer;
    begin
        i := 1;
    end.</code></pre>

On my page, I want to format C++ code. So I'll need something like class="language-cpp" (That's a guess). Anyone know what it is? Or is there some documentation where I can see a list of the classes?

Community
  • 1
  • 1
  • Are you aware that the suggestions in your link are not part of HTML5 but of syntax highlighting scripts? – Jongware Jun 03 '14 at 21:07
  • @Jongware he is referring to Paul's answer there. – Joeytje50 Jun 03 '14 at 21:08
  • Though Pauls answer says "I don’t know of any web browser that does anything with this attribute (come on, Chrome), but the JavaScript syntax highlighters mentioned in other answers may use it to work their magic" – Ben Bartle Jun 03 '14 at 21:09
  • possible duplicate of [HTML5 code element - language class](http://stackoverflow.com/questions/8777637/html5-code-element-language-class) – Jongware Jun 03 '14 at 21:10
  • Okay, got that. Tip: press the `share` button next to any *answer* to get a direct link to it. – Jongware Jun 03 '14 at 21:12
  • "language-cpp" seems like a good guess. If I were writing a syntax highlighting script, that's what I'd use for C++. If the script you end up using differs, you can change them with a simple find-replace. – BenM Jun 03 '14 at 21:15

1 Answers1

2

According to the w3 page this code originally came from, this is simply a semantics suggestion, nothing more. This class doesn't affect the browser in any way other than any other class would, and it's simply a recommendation from W3 to use classes like that when highlighting your code.

There is not, and will never be, anything this class will do by itself. You'll have to include a syntax highlighting script for the code to work, and those all will have their own documentation which will all be clear on how to highlight code for C++.

Joeytje50
  • 18,636
  • 15
  • 63
  • 95