I am facing a really annoying issue with the HTML pre
element. I have no idea why it's creating so much white spaces when I never actually did that. Inside my code editor, everything is properly indented, made sure that the HTML is 100% valid but whenever I test on my browser; the white spaces suddenly appear. To make things more understandable, here's an image of how the pre
looks inside my console.
And here's the HTML / CSS code.
HTML
<pre>
<!DOCTYPE html>
<html>
<head>
<title>My website<title>
</head>
<body>
<script type="text/javascript">
alert("Hello world!");
</script>
</body>
</html>
</pre>
CSS
pre{
overflow: auto;
background: #ddd;
padding-left: 10px;
padding-bottom: 10px;
padding-top: 10px;
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
white-space: -ms-pre-wrap;
}
If it helps, I am also using ratchet in order to make it mobile ready. (Please note that removing the white-space did not help). Regards.
The white-space property specifies how white-space inside an element is handled.
Whitespace error can be caused by either an unsupported character or symbol being passed to the gateway, or a blank or white space being left in a field. Most commonly, the Whitespace error is caused by characters or symbols that are not supported by global XML code being passed to the gateway.
White space, also known as “negative space,” is empty space around the content and functional elements of a page.
We can also remove white space by setting parent element font-size to 0 and child elements font-size to 17px .
Instead of:
white-space: pre-wrap
Use:
white-space: pre-line
DEMO
white-space
The
white-space
property is used to describe how whitespace inside the element is handled.pre-wrap
Sequences of whitespace are preserved.
pre-line
Sequences of whitespace are collapsed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With