Horje
How to create HTML <code> For Computer Code Part - 2

Notice that the <code> element does not preserve extra whitespace and line-breaks.


Example of HTML <code> For Computer Code Part - 2

To fix this, you can put the <code> element inside a <pre> element:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p>The code element does not preserve whitespace and line-breaks.</p>
<p>To fix this, you can put the code element inside a pre element:</p>

<pre>
<code>
x = 5;
y = 6;
z = x + y;
</code>
</pre>

</body>
</html>

Output should be:

Example of HTML <code> For Computer Code Part - 2





Related Articles
What is HTML Computer Code HTML Computer Code
How to create HTML <kbd> For Keyboard Input HTML Computer Code
How to create HTML <samp> For Program Output HTML Computer Code
How to create HTML <code> For Computer Code HTML Computer Code
How to create HTML <code> For Computer Code Part - 2 HTML Computer Code
How to create HTML <var> For Variables HTML Computer Code

Single Articles
Example of HTML <code> For Computer Code Part - 2HTML Computer Code

Read Full:
HTML Computer Code
Category:
Web Tutorial
Sub Category:
HTML Computer Code
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
164


Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_formatting_codepre

Share on: