Reputation: 4148
I have this line:
<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>
That is part of a code element.
What I'm trying to do is to view the line on small screens (without horizontal scrolling).
I have tried to style both <pre>
and <code>
with the help of http://www.w3schools.com/css/css3_text_effects.asp - and still the line doesn't break!
code {
width: 90%;
min-width: 200px;
background-color: white;
border: 1px solid black;
margin: auto;
font-size: 1rem;
/* ... and now what? */
}
Upvotes: 1
Views: 1945
Reputation: 2604
Using the overflow-wrap CSS property should fix your issue
code {
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
}
Upvotes: 3
Reputation: 2475
code {
overflow-wrap: break-word;
}
From Mozzila Dev documentation
This is working on:
Upvotes: 0
Reputation: 123
All that you need is to add: word-wrap: break-word;
http://www.w3schools.com/cssref/tryit.asp?filename=trycss3_word-wrap
Upvotes: 1