Improved Vertical Text Spacing with CSS

Do you want to share WYSIWYG Web Builder tips, tricks, tutorials or useful HTML code? You can post it here...
(no questions or problems please, this section is not monitored by support).
Forum rules
This section is to share tips, tricks and tutorials related to WYSIWYG Web Builder.
Please do not post questions or problems here. They will not be answered.

PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
Post Reply
User avatar
gofrank
 
 
Posts: 181
Joined: Sun Dec 30, 2007 2:43 am
Location: Florida, USA

Improved Vertical Text Spacing with CSS

Post by gofrank »

Just about everyone who has designed a page for the web has found the problem with web browsers: each browser renders the spacing of text blocks in a different way. This is not the fault of Web Builder or any of the other HTML design programs; each browser has its own rendering engine that follows its own interpretation of the rules.

While redesigning one of my web sites, I started using CSS to adjust the line height of text objects. It occurred to me that part of the problem with the different browser engines might be that they each use a different "default" line spacing. Then I thought: what if we specify a line height for text; would that override the browser's default and perhaps give us a better, more consistent spacing across more browser platforms?

Some testing was in order. First, in WB I created a new CSS style and gave it a CustomStyle of line-height:16px.

Image

Next, I created a test page consisting of three columns of text.
  • Column 1 - A single large text object with our CSS style applied
  • Column 2 - The same single text object with NO CSS
  • Column 3 - The same text with each paragraph in a separate text object, all with CSS
(Breaking up large text objects into smaller, individual objects has been the standard way in WB to minimize text rendering problems across browsers.)

At the bottom of each column is a horizontal line positioned one pixel below the baseline of the last line of text.

The goal of the test: by adding a CSS line-height specification, could we keep the text within the vertical space allotted by our design regardless of the browser used? In other words, can we keep the last line of text from crossing our horizontal line?

After running the page through browsershots.org, the answer appears to be: usually.

First of all, the good news. Depending on the operating system, rendering of WB pages can be very good. For example, all of the browsers under Windows did a good to excellent job of keeping the text within bounds. There was virtually no difference between the columns and the CSS settings made no difference under IE, Firefox, Safari, and Chrome.

However, when browsers under Mac's OSX 10, Ubuntu, FreeBSD, and others came into play, the CSS made quite a bit of difference.

For example, Safari 3.2.3 under Mac OSX 10.5 rendered both CSS columns (one single text object vs. separate text objects) the same while the block with no CSS came up short.

Under FreeBSD, Konqueror 3.5 had problems with the test page. Column one with CSS ran past the end of our boundary slightly. Column two with no CSS was the biggest offender, going twice as far past the boundary. But column three with CSS stayed within the boundary while sacrificing spacing between paragraphs. This latter condition appeared to be common with most of the fringe browsers. However, the text did NOT overlap and was completely readable.

So, the bottom line is that by applying the line-height style to your custom CSS, most (but not all) of the spacing problems with text rendering between browsers can be minimized. The result is not perfect--and probably never will be. But you'll sleep better at night knowing that someone viewing your site using CrackerJack 2.1.2 under the Cardboard 8.9 operating system will see pretty much what you (and everyone else) sees.

That should be worth something.
Billing clients for your freelance work? Try Minute-2-Minute, the project management, timing, and billing system. Perfect for web developers who charge by the hour. FREE 45-day trial.
User avatar
bry
 
 
Posts: 176
Joined: Fri Jan 11, 2008 8:44 pm

Post by bry »

Hi GoFrank,

Just one tiny note since your work is such perfection. Your test page is untitled. Thanks so much for this and any other help you take time to give!!
User avatar
bry
 
 
Posts: 176
Joined: Fri Jan 11, 2008 8:44 pm

Post by bry »

The first column says, "with our" ... does that mean "WB"?
User avatar
gofrank
 
 
Posts: 181
Joined: Sun Dec 30, 2007 2:43 am
Location: Florida, USA

Post by gofrank »

Bry:

"Our" actually meant "anyone" who wanted to apply a CSS line-height value. The test page really is a test page (which is why it is untitled).

Since I did this test, I've started applying styles to all the text on my sites. Doing so makes it extremely easy to change fonts, sizes, colors, etc. throughout the site without the need of selecting each block of text on each page individually. The ability to help control the line height of the text is a bonus.

It is amazing to see how much WB has grown in ability over the various upgrades. The program just keeps getting better and better.
Billing clients for your freelance work? Try Minute-2-Minute, the project management, timing, and billing system. Perfect for web developers who charge by the hour. FREE 45-day trial.
Post Reply