The white-space
property in CSS-3 has the pre-wrap
value, which will preserve whitespace and line breaks, and wrap when necessary, and the pre-line
value, which collapses whitespace, but preserves line breaks, and wraps when necessary.
What it does not have, though, is a value that preserves whitespace and collapses line breaks, while still wrapping otherwise.
Is there a combination of other CSS properties that I can use to get this effect?
For example:
This example
code
should render
on one line but
with spaces intact.
should look like:
This example code should render on one line but with spaces intact.
Answer to your question: no, there is no way to do it by only using CSS
(prove for white-space
)
There is no line such as: collapse | preserve | ...
The only way to do it is by using JavaScript
document.body.innerHTML = document.body.innerHTML.replace(/\n/g, '');
html {
white-space: pre-wrap;
}
This example
code
should render
on one line but
with spaces intact.
Hardcode methods
1st
* {
white-space: pre-wrap;
}
br {
display: none;
}
This example<br/>code<br/>should render<br/>on one line but<br/>with spaces intact.<br/>
2nd
This example
code
should render
on one line but
with spaces intact.
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