How can I show HTML code snippet on webpage
Is there any tag or something?
6 Replies
To render code snippets on a webpage requires a few steps:
The
pre
tag is for pre
formatted text, so it doesn't collapse white space and the code
tag styles the text to look like code and not regular text.
Step 2 is to use HTML escape sequences for certain characters, most notably <
and >
. As an example, >
will give you >
and <
will give you <
. You do this because otherwise the browser will see the <
and >
and assume what's between is an element and try to parse it normally.@cvanilla13eck it worked, Thank you very many
👍
should i close post now or tag it solved?
I just tagged it
No need to close it as it'll close automagically later
Keep it open and in the "recently posted in" section in case someone wants to see the solution
ok