How can I show HTML code snippet on webpage

Is there any tag or something?
6 Replies
13eck
13eck3y ago
To render code snippets on a webpage requires a few steps:
<pre>
<code>
<!-- code snippet goes here -->
</code>
</pre>
<pre>
<code>
<!-- code snippet goes here -->
</code>
</pre>
The pre tag is for preformatted 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, &gt; will give you > and &lt; 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.
JOY
JOYOP3y ago
@cvanilla13eck it worked, Thank you very many
13eck
13eck3y ago
👍
JOY
JOYOP3y ago
should i close post now or tag it solved?
13eck
13eck3y ago
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
JOY
JOYOP3y ago
ok
Want results from more Discord servers?
Add your server