View Full Version : Preventing line breaks

04-24-2006, 01:39 PM
How can I prevent text from line breaking? In the example below, I want the phrase after the word PNGOut, not to be moved to the next line (please see screenshot: http://xs78.xs.to/pics/06171/linebreak.PNG.xs.jpg (http://xs.to/xs.php?h=xs78&d=06171&f=linebreak.PNG))

Here is the code for that line:
<a href=' http://brh.numbera.com/software/pnggauntlet/'>PNGGauntlet</a><div class = 'txt'>thorougly compresses PNGs (more compressed than usual image viewer/editing programs), a frontend for</div><a href='http://www.advsys.net/ken/utils.htm'>PNGOut</a><div class = 'txt'>, a utility that optimizes the size of .PNG files without losing any information. With the right options, it can often beat other programs by 5-10% (including PNGCRUSH -brute). PNGOUT is a great tool for optimizing the size of web pages.</div><br/>

04-24-2006, 01:48 PM
Change the <div> tags to <span> tags. The text should line break as normal.

04-24-2006, 01:52 PM
You marked up the text outside the two links with divs: both inappropriate and unnecessary, and since divs are block level elements by default they flow underneath any previous content.

In this case, if you want to have the two links flow with the rest of the text, simply mark up the entire section with a p (no divs) and style the two links as before.
If you want the second link to start at a new line, a br could be used to terminate the previous line.

04-24-2006, 02:06 PM
Arbitrator, the <span> tags worked. Thanks. I am quite new to HTML and CSS, so my webpages are a bit problematic..

ronaldb66, thanks for the suggestion. If I understand correctly, are you suggesting that I put the entire code I previously posted inside a <p> tag? I want to style the text outside of the links using CSS without affecting the links themselves (those inside <a>), that's why I put the div tags. Can you suggest a sample code for this?

04-24-2006, 02:10 PM
Sure thing. And yes, he meant to use the paragraph tags on the whole paragraph. Your links can be styled independent of the normal text.

04-24-2006, 02:19 PM
Your links can be styled independent of the normal text. Exactly: approach the other text in the p as "normal" text, and address the links' styling using the a element selector.

I know the spans "work", but they're extra markup and are not necessary.
Also, by using a p element to mark up what is essentially a paragraph of text (semantic markup), you get the default top and bottom margins--which you seem to try and emulate using extra br elements--on the p for "free".

04-24-2006, 02:30 PM
I see. Thanks.