Prevent Long URL's From Breaking Your Layout

It has become increasingly important to make sure your layout doesn't break when viewing your Website on a phone. So what do you do when, in Android or Google Chrome, you notice that your layout is blowing out because of an especially long word (or line of unbroken text, like a URL)?

It turns out, there's a specific fix for this very problem. In your CSS, target the container in which the troublesome URL (or ridiculously long word) is pushing out your container, and add this declaration:
word-wrap: break-word;

For example:


.content { word-wrap: break-word;}

This will take care of the problem in most cases. HOWEVER! If you are experiencing this problem inside of an HTML table (and yes, occasionally we do have to put a URL inside a table per the needs of the project or client), you'll need to add another rule to your CSS.

Specifically, you need to tell the HTML table to stop listening to that pesky URL that wants to make it wider than you want it to be. You do this in your CSS by giving the table a rule with the declarations:
table-layout:fixed; width:100%;

For example:


.content table { table-layout:fixed; width:100%;}

(Note: you don’t have to set the width to 100% – it can be 90%,50%, or whatever – but you do need to set a width of some kind; percentages are highly recommended when creating a responsive layout; pixel widths will get you into trouble.)

It’s not often I run into this problem, but it happens just enough that I decided to finally document it here, instead of going out to Google it every time I have to solve it.

A big thanks goes out to CSS-Tricks.com for providing the original post that informed this solution.

Comments

I don't know if it's just me or if perhaps everybody else encountering issues with your site. It seems like some of the written text in your content are running off the screen. Can somebody else please provide feedback and let me know if this is happening to them too? This could be a issue with my browser because I've had this happen before. Appreciate it

Yet, despite the many years Olunde has splent in Europe, he ends uup killing himself after his father is arrested to prevent him from performing the ritual killing. you cann also create an acronym from the checklist of pieces that you simply do not need to forget. rescue his father, they both thrn try to escaoe oout of Brooklyn.

Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!

M Newbold is a prolific writer who enjoys writing about family life, health, fitness and sports. However, it is notable that this mystical sect was not mentioned in thhe New Testament, except ffor the various references regarding the men in white whoo appeared in Jesus' tomb, and at the time of his Ascension. I most certainly couldn't, and that's with my years of experience.

I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this increase.

Hеlloo there, I dіsϲߋvered your website by means of Gokgle whilst searching ffor a similar sսbject, your web site came uƿ, it appears to be like good. I Һave bookmarked it in my google bookmarks. Hi there, just was alert too your weblog via Google, and locwted that it's truly informative. I'm gonna watch outt for brussels. I'll aρpρreciate shоuld you continue this in fսture. A lot of other folks shall be benefited out off your writing. Cheers!

When the face in the mirror changes back to the one you have in this life or you become tired, begin writing down all of your impressions and the answers to your questions if your are journaling to record the experience. Every 11 years there is a pole reversal in the sun, which is peaking now, which causes massive solar flare ups. If the activation fee is discounted, ask for it to be waived completely.

Add new comment