Forum Moderators: not2easy

Message Too Old, No Replies

Font Size Problems When Page Source is Translated

'Normal' page is fine, but in G-Cache, translated etc the font-size wrong

         

AlexK

8:20 am on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The CSS uses techniques lifted from the NoodleIncident [thenoodleincident.com]:

body {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 76%;/* font sizing in ems; */
}
h1 {
font-size: 2.0em;
font-style: italic;
font-weight: normal;
}
etc

So, the body sets the font-size at 76%, and everywhere else sizes are declared in ems. It all validates, and works well in every browser. With one exception...

In the Google cache, or when translated by Google, Yahoo or Altavista, page fonts are very much larger for every table except the first one. It seems that the "76%" font-reduction is no longer in effect, except for the first one! What on earth is going on!

To recap, the page is laid out with tables:


.--------------------------
¦ top-table ............. ¦
¦ (this is fine) ........ ¦
.--------------------------
.-------- . ---------------
¦ Other. ¦ ¦ ............ ¦
¦ Tables ¦ ¦ ............ ¦
¦ (not). ¦ ¦ ............ ¦
¦ ...... ¦ ¦ ............ ¦
.-------- . ---------------

(pre + code is broken in these forums, so the above will look wierd)

The very top table has the correct (76%) font size, but all other tables do not. Does anybody know why this may be?

The page source does gets rewritten. eg:

Yahoo translation:
<head>
<title>Versión traducida de {page-url}</title>
</head>
<html><meta http-equiv="content-type" content="text/html; charset=UTF-8"><base href="{page-url}"><!doctype html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<!-- removed -->
<meta http-equiv="Content-Type" content="text/html ; CHARSET=UTF-8"><head>
<title>Conexant RH56D/SP-PCI 56k HCF DFS</title>
...
</head>
<body>
...
(notice that there are now 2 <head>s. The problem is not due to that, however:

AltaVista translation:
<html><meta http-equiv="content-type" content="text/html; charset=UTF-8"><base href="{page-url}">
<!doctype html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<!-- removed -->
<meta http-equiv="Content-Type" content="text/html ; CHARSET=UTF-8"><head>
<title>Conexant RH56D/SP-PCI 56k HCF DFS</title>
...
</head>
<body>
...

encyclo

8:24 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you make a test-page and remove the doctype off the top of the markup, do you get the same effect? I believe the problem is that the percentage font-size technique is dependent on triggering standards-compliance mode in the browser when dealing with tables (I don't remember the exact details, but font-sizing in tables cascades weirdly in quirks mode). The cache / translation tools add their own code to the top, pushing the doctype out of the way and triggering quirks mode in the browser, hence the font-size error you are seeing.

AlexK

2:10 am on Nov 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Pretty good, encyclo, correct first time!

I did 2 tests:

  1. The translated page-source with DTD moved back to the topline
  2. 'Normal' page-source with DTD removed.

(1) became correct layout, and (2) looked exactly like the translated pages. Damn, I've been puzzling over this for years, and you got it first time! Excellent work.

I suspect that the next question is more difficult: is there any means of adjusting the CSS so that the "76%" will transcend down to all fonts, wherever they are on the page, whether Standards-Mode or Quirks-Mode? After all, the top-table renders correctly, so it must be possible for the other tables, too.

[I asked myself "What is the difference between the top-table and all other tables?". Here is the answer]:

Top Table:

<body>
-> <table>
-> -> <tbody>
-> -> -> <tr>
-> -> -> -> <td>
-> -> -> -> -> <h1>
-> -> -> -> -> -> text

Other Tables:

<body>
-> <table>
-> -> <tbody>
-> -> -> <tr>
-> -> -> -> <td>
-> -> -> -> -> <div>
-> -> -> -> -> -> <h1>
-> -> -> -> -> -> -> text

So, I guess the question becomes:

"How is it possible in Quirks mode to cause the Body->76% to transcend down through the CSS hierarchy past the <div> to reach other elements, yet not render incorrectly in Standards mode?"

It seems to me that this is the sort of question that separates the boys from the men. I am definitely a boy in this.

AlexK

8:39 am on Nov 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am astonished to say that I have fixed this.

It turned out to be the treatment of <table> in Quirks mode, and nothing whatsoever to do with <div>.

After hours of reading various articles on the web, and using the DOM Inspector in Mozilla (Ctrl+Shift+i - what a great browser Mozilla is for developers and Webmasters), I was able to see that Moz added an extra stylesheet in Quirks (resource://gre/res/quirk.css) and that for tables this contained the line:

font-size: initial

Thus, every <table> was ignoring the "font-size: 76%" in the site style-sheet.

Now, this is the declaration for the top-table:

table#Top {
font-size: 1.0em;
margin: 0;
padding: 0;
}
...and that font-size: 1.0em; allowed the top heading to keep the correct text sizes. None of the other <table>s had it. Naturally, they do now, and the page looks (mostly) OK when viewed in the translated versions or the Google cache in both Mozilla and Internet Explorer.

Wow, only 2 years to fix! Many thanks for your assistance, encyclo.