Block with and
If the formatting (white space, new lines, indentation) of the code matters, use the pre element in combination with
the code element:
x = 42 if x == 42: print "x is … … 42"
You still have to escape characters with special meaning in HTML (like < with <), so for displaying a block of HTML code (
This is a paragraph.), it could look like this:<p>This is a paragraph.</p>
Inline with
If a sentence contains computer code (for example, the name of an HTML element), use the code element to mark it
up:
The
a
element creates a hyperlink.