Text wont Wrap (CSS)

Text wont wrap in firefox

Just done some updates on my website and I've noticed the code box text does not wrap any more?
It works fine in Safari but when I open it in Firefox or Opera this happens;

text wont wrap
source URL:https://www.petenetlive.com/KB/Article/0001469

Whats wrong in my CSS?

Im probably going to be asking a few questions today :(
LVL 58
Pete LongTechnical ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
By default, <pre> tags won't wrap. They're designed specifically not to. You could add wrapping by using the white-space declaration:

pre { white-space: pre-wrap; }

An alternative approach may be to just add a scroll bar. If it's important that the lines don't wrap (i.e. you're showing code block), then just add an overflow to the <pre>

pre { overflow: auto; }

Now you code will remain on the correct lines, but you'll be able to scroll horizontally.
0
Pete LongTechnical ConsultantAuthor Commented:
cheers Chris

I already have this in my child theme css

pre {
word-break: break-all; /* webkit /
word-wrap: break-word;
white-space: pre;
white-space: -moz-pre-wrap; / fennec /
white-space: pre-wrap;
white-space: pre\9; / IE7+ */
}

shouldn't that be fixing the problem?
0
Chris StanyonWebDevCommented:
Hey Pete,

Yes it would ... except the css that you posted has an error in it. Everything between /* and */ is treated as a comment - you've basically commented out everything apart from the first line. Remove all the comment tags and you should be fine. If you want the comments, then wrap each one on it's own:

pre {
word-break: break-all; /* webkit */
word-wrap: break-word;
white-space: pre;
white-space: -moz-pre-wrap; /* fennec */
white-space: pre-wrap;
white-space: pre\9; /* IE7+ */
}

Open in new window

For code snippets, I would still recommend the scrollbar though! As a coder, I find it annoying when code lines break where they shouldn't :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Julian HansenCommented:
(no points) - definitely agree with Chris on this - use the overflow: auto rather than the wrap - it is what most sites that display code snippets do so it is understood - and in my view preferable to wrapping.
0
Pete LongTechnical ConsultantAuthor Commented:
I added the overflow auto - now it behaves in safari / IE, Opera still wont work but hey-ho

pre {
word-break: break-all; /* webkit /
word-wrap: break-word;
white-space: pre;
white-space: -moz-pre-wrap; / fennec /
white-space: pre-wrap;
white-space: pre\9; / IE7+ */
overflow: auto;
}

Open in new window

0
Pete LongTechnical ConsultantAuthor Commented:
Right we were typing at the same time - I will fix accordingly Thanks Guys

Another Question coming soon
0
Pete LongTechnical ConsultantAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.