HTML5 tag to display syntax highlighting

I was wondering if there is a tag that automatically emphasizes the syntax of HTML and PHP in HTML5. I am writing a guide in which there is code. Since I use a lot of new html5 tags (I use a section to outline my guide), I would like to use something in my own html5.

If this does not exist, what is the best way to do this? (Like, PHP and CSS?)

+4
source share
3 answers

There is nothing like this in HTML5, I'm afraid, but you can always use highlight_string() from PHP. If you want something purely on the client side, try highlighting the JS shortcut as prettify, and this is what StackOverflow uses to highlight the code:

http://code.google.com/p/google-code-prettify/

Here are some others:

+8
source

HTML5, like any other version of HTML, is designed to define content and structure. You designate blocks of code with <pre> , <code> , etc., but you donโ€™t use HTML to tell the browser something should look like, so there isnโ€™t such an element to tell the browser syntax to highlight a block of code.

The syntax highlighting, thus, falls under the area of โ€‹โ€‹style, design, etc., which is processed by CSS. As suggested by NullUserException (there are some great links!), You can use JavaScript syntax to highlight the code for you on the client side (for example, the one on Stack Overflow), or do it on the server side, and output it to computer style HTML blocks from the server language.

+2
source

All Articles