tag
I use the tag in my blog to post code. I know I have to change
<
to <
and >
to >
What happens if you use the tag to display HTML markup on your blog:
Use a span tag with style attribute to hightlight words
This will pass HTML validation, but does it produce the expected result? No. The correct way is:
Use a <span style="background: yellow;">span tag with style attribute</span> to hightlight words
Another example: if you use the pre tag to display some other language code, the HTML encoding is still required:
if (i && j) return;
This might produce the expected result but does it pass HTML validation? No. The correct way is:
if (i && j) return;
Long story short, HTML-encode the content of a pre tag just the way you do with other tags.