How to add a code section in webpage

How to add a code in webpage like this using html HTML and CSS. :arrow_down:

Here to add a code section inside your topic  
we use  tag ''' code here ''' but this tag don't 
work in HTML.

I haven’t done this much but I’d strongly advice making use the the HTML <code> tags you can learn about that using HTML code tag .

Then you can head to CSS to style this whichever way you desire.

But my favorite way of doing this is by nesting my <code> in pre tags to preserve the whitespaces for example:

<pre>
<code>
your code snippets go here…
<code>
</pre>

You can find more information about the pre tag at HTML pre tag.

An alternative would be setting up just the code tags with the content and then style them in the CSS. You can use the white-space property also to preserve white-spaces in your snippets this resource has more info on white-space property white-space - CSS: Cascading Style Sheets | MDN.

Thank you for reply, I’ll do like that