The Developer Brains


HTML Computercode

Web Designing | Web Development


SEE MORE














</Marking up computer code in HTML>





Marking up computer code in HTML

If the formatting (white space, new lines, indentation) of the code matters, use the pre element in combination with the code element:


SEE MORE




















</Marking up computer code in HTML. >


Block with <pre> and <code>

         
<pre>
   <code>
    x = 42
    if x == 42:
       print "x is ... 42"
   </code>
</pre>
         	
				
Try it Yourself

You still have to escape characters with special meaning in HTML (like < with &lt;), so for displaying a block of HTML code (<p>This is a paragraph.</p>), it could look like this:

         
<pre>
   <code>
    <p>This is a paragraph.</p>
   </code>
</pre>
         	
				

Inline with <code>

If a sentence contains computer code (for example, the name of an HTML element), use the code element to mark it up:

         
<p>The <code>a</code> element creates a hyperlink.</p>
         	
				

Add Highlight Source on youe website















</HTML> Quiz Question>


Which tag is use to display computer code?



Check Now



HTML5 QUIZ







Next: HTML Marking up quotes


Previous

      

Next Page













  Share TDB SCHOOL  

Share this E-Learning Website on social media platforms with your friends and followers