4
Example code without indentation
/*Exibindo trecho de código no HTML utilizando o <pre><code>*/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<pre>
<code>
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<p>This example calls a function which performs a calculation, and returns the result:</p>
<p id="demo"></p>
<script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script>
</body>
</html>
</code>
</pre>
</body>
</html>
Code Indented:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<pre>
<code>
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<p>This example calls a function which performs a calculation, and returns the result:</p>
<p id="demo"></p>
<script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script>
</body>
</html>
</code>
</pre>
</body>
</html>
Thus the arquivo.html
is indented but it modifies the way the element <pre><code>
and viewed on the page.
How can I align the code snippet to the left without disturbing the indentation of the arquivo.html
?
Disrupt identation? You want it to automatically align?
– Laerte
I want the code snippet to be displayed left-aligned independently of the way the code is written inside the <pre><code>
– stringnome