Code tag on Firefox

Posted by Zeno on Thu 03 Mar 2005 07:19 PM — 39 posts, 136,765 views.

USA #0
Anyone else here have a problem with Firefox and the code tag? I've viewed code tags with Firefox on multiple computers, so it may be a Firefox problem.
This text looks very small in Firefox

Sometimes if I refresh the page a lot it'll return to normal.

Here's the source via Firefox of a code tag:
<font size="-1"><table width="100%"><tr><td><font size=2><pre><code><font size=2>Wed Mar  2 15:29:16 PST 2005


[EDIT] Here's a screenshot:
http://img.photobucket.com/albums/v123/rebirthseph/gamfirefox.jpg
Amended on Thu 03 Mar 2005 07:21 PM by Zeno
USA #1
Yeah I use firefox and I have that same problem as well..

Im not sure what its all about and actually its rather annoying..
If anyone has a way to stop it I for one would like to know how
USA #2
I have the exact same problem. I also have weird issues where I go to the main forum page, and lines are spaced close together, and if I refresh, it goes away.

It's probably a bug in Firefox. I've just been waiting for a new version to come out. :)
USA #3
Yeah speaking of a new version, 1.0.1 just came out. (I just told me to update 5min ago)

I started this topic:
http://forums.mozillazine.org/viewtopic.php?t=228998

Try to keep it bumped or something? I dunno.
Amended on Thu 03 Mar 2005 08:33 PM by Zeno
USA #4
I wonder if it's the <font size = -1> in the beginning.

I'll go update now. :) (Wheeeee)
USA #5
I have the new update .. Still does it to me
USA #6
Yeah new update didn't fix it. Maybe they don't know about it.
USA #7
Yes, the new update claims to address stability and security. Chances are the bug is a result of the combination of tags that Nick uses, which for some reason Firefox isn't happy with. Still, they look fine to me... *shrug*
USA #8
Does firefox get fickle about other page's font size not being in quotes? The <font size=2> 'should' be <font size="2">

Or is it the code tag itself?

I imagine however, Nick uses sizes without quotes other places without problems.
USA #9
Yeah, code tags are small for me as well. Using Firefox 1.0.1 but I always thought it was intentional. I'm not sure that Firefox is so picky about the font tag format that it would just ignore the missing quotes. I've seen it properly render some stuff an HTML validator writes books of errors for.
USA #10
Well, the funny thing is that it's small, but then if you refresh the page, it grows again... sometimes I find that as I read a post, it's small, but as I reply to it, the code tags are suddenly larger again. Very strange...
USA #11
Then it's definately a bug in firefox. Regardless of what 'should' be displayed, it should be displayed consistantly. Might try submitting it to bugzilla if you can't find it in there.
USA #12
I submitted a bug, since I don't know the exact cause.

https://bugzilla.mozilla.org/show_bug.cgi?id=284792

I sort of rushed through the submittion, so add any comments if you wish that would help to figure out the problem.
USA #13
Bug was responded to:
Quote:
Both <pre> and <code> cause the use of monospace fonts. The default monospace
font in FF is 3 or 4 sizes smaller than for proportional. To these smaller fonts
is applied <font size=2> which makes them smaller still.

Go into your options for fonts and either make the size bigger, and/or choose a
font family for monospace that renders larger, such as Bitstream Vera Sans Mono
(a free download font).
USA #14
Then why does it display differently at different times?
USA #15
Yeah. The bug isn't so much the funny display, but the inconsistent display and how it changes after refresh etc.
USA #16
https://bugzilla.mozilla.org/show_bug.cgi?id=284792

I saved this first page, and uploaded it there. All but (obviously) the images remained. Yet the problem does not exist. Only here.
USA #17
After updating to 1.5, I still notice this problem. So I asked around a bit.

Quote:
I'm pretty sure using a font element there isn't valid. Who knows what will happen when you use crazy html. Wink

W3C Markup Validation Service wrote:
Error Line 223 column 23: document type does not allow element "FONT" here.

<pre><code><font size=2>

how about
Code:
<code style="font-size: larger">...
or whatever size is appropriate.


http://validator.w3.org/check?verbose=1&uri=http%3A//www.gammon.com.au/forum/bbshowpost.php%3Fbbsubject_id%3D6085%26page%3D999999

Perhaps you aren't suppose to use font tags in the code tag?
Amended on Thu 01 Dec 2005 08:04 PM by Zeno
USA #18
Perhaps an even bigger problem being that there is no valid doctype or character encoding in the html either. Without the doctype the browser falls into "quirks mode" and it basically becomes a free-for-all. The behaviour end up being determined at the whim of the browser.
USA #19
I tested it locally, changing the source to <code style="font-size: larger"> as suggested, and it seems to be fixed.
Australia Forum Administrator #20
OK, the pressure's on, I can see that. :)

The problem from my point of view is that the code tags are not generated in a single place, for historical and other reasons.

For example, when I do HTML inside a forum post (which is not *that* often) I manually insert the code tags.

Also the static web pages will have them all over the place. The forum tags (where you use the [code] tag) are naturally generated in a single place.

I'll try to fix it.
Australia Forum Administrator #21
Quote:

Anyone else here have a problem with Firefox and the code tag? I've viewed code tags with Firefox on multiple computers, so it may be a Firefox problem.

This text looks very small in Firefox


Now here's a funny thing. I downloaded the latest version of Firefox, and the "code" text looks OK, much the same as in Internet Explorer.

I can work on the validation errors, but I can't see a major difference to the way the forum appears in the two browsers.
USA #22
Try a refresh a few times. Like Ksilyan said, it's a weird inconsistent display issue.

I could care less about validation errors, the only issue with the site that bugs me is this code display issue. Actually I really don't even notice any other issues.

Here's what it looks like normally:
http://www.rebirthseph.noobify.com/ff_font1.bmp

This is when it becomes a problem:
http://www.rebirthseph.noobify.com/ff_font2.bmp

It seems to randomize between normal font size and that one small font size.
Amended on Fri 02 Dec 2005 08:08 PM by Zeno
Australia Forum Administrator #23
Quote:

Try a refresh a few times. Like Ksilyan said, it's a weird inconsistent display issue.


To be honest, if refreshing randomly displays different data, this is definitely a bug in the browser. Surely, no matter how bad the HTML is, it should be rendered consistently?

Quote:

how about
Code:
<code style="font-size: larger">...
or whatever size is appropriate.


I have done that, see how that goes (this is for forum [code] tags only right now).

It looks OK in Firefox, however now in IE I get the weird effect that the font looks too *small* for [code] tags, but OK for [mono] tags. That is really strange. The only difference is that the [code] tags use the <pre> tag, which is just supposed to retain linebreaks and indenting. Oh well, I'll research that some more.

Quote:

Perhaps an even bigger problem being that there is no valid doctype or character encoding in the html either.


The HTML header now has a DOCTYPE and character encoding tag.



USA #24
Quote:
I could care less about validation errors, the only issue with the site that bugs me is this code display issue. Actually I really don't even notice any other issues.


The only reason I mention the validation errors is that they may, in their cryptic wisdom, be pointing to the reason why this is happening. I've seen validation errors trigger inconsistent behaviour in Firefox, IE, Opera, and in Konqueror. So it certainly won't *HURT* to correct those.

As for the specific issue in this case, I've seen the code tag inconsistency in Firefox, IE, and Opera, and every time it changes it's been after either a page refresh or clicking to a new topic. So that leads me to beleive the fault is somewhere in the html, not in the browsers.
Australia Forum Administrator #25
I would like my pages to validate correctly, but the major problem is that, in my ignorance of HTML when I first started writing them, I did something like this:


<html>
<head>
<title>Page title</title>
</head>
<body">
<FONT FACE="Verdana, Arial, Helvetica, Geneva" SIZE="-1">

<!--  entire rest of page here -->

</font>
</body>
</html>


Now basically I don't think you are supposed to do that - try to make a font global for the page. I think a lot of the validation errors arise from that.

I experimented for a while with CSS, but with pretty variable results. Like the font would switch to some ugly default in things like the "login" dialog box, or lots of places.

To do it properly would really take a pretty big rewrite, paying close attention to the current HTML standards, and keeping a lot of things (like colours) as separate control-file (or user file) entries.

If someone can demonstrate a simple way of changing the page (just take the generated HTML and play with it), so that the validation errors go away, but without major changes, then I would be pleased to hear from them.

I have fixed a few things in the last few days, like making <hr> to be <hr/>, <br> to be <br/>, <img blah blah> to be <img blah blah/> and so on. Plus, of course, the doctype and character encoding mentioned earlier.
USA #26
Since you are validating for HTML 4.01 you should stick to using <br> and <hr>. The trailing slash thing is only necessary to validate for the XHTML 1.0 and 1.1 standards.

You can of course use CSS, and it may help to do so. Cuts down on alot of the redundant stuff. Though I am no guru myself with HTML/CSS I can lend a hand with what I have picked up from my own pages and from development work on QSF.
USA #27
May be able to start off with the simple stuff - like this:

<a href="/forum/"><img src="/images/forum.gif" alt="[Help/forum]" width=95 height=27 border=0/></a>

The img tag in 4.01 also does not require the / before closing the tag. The width, height, and border attributes should also be enclosed in quotes. The validator isn't complaining but it could still be influencing things.
USA #28
Quote:
To be honest, if refreshing randomly displays different data, this is definitely a bug in the browser. Surely, no matter how bad the HTML is, it should be rendered consistently?


This is what someone said on the Mozilla forums when I brought up the random display:
Quote:
Zeno, if you throw Firefox into quirks mode (say for example you leave out the DOCTYPE declaration, which is a great way to confuse a standards-strict browser) you create the condiditons for the possibility that it will render differently at each request. If you make typographic errors in the code, you have the possibility that it will make a randomly alternate pick each time of what the code might be. Which, given where your typo is, would achieve pretty much the effect you are seeing.

I'm not sure it could fairly be described as a bug in the browser that it renders incorrect code incorrectly in a random manner, rather than incorrectly in a consistent manner, given that it makes no claims regarding rendering incorrect code at all.
Amended on Sun 04 Dec 2005 03:43 PM by Zeno
USA #29
I'm working with a source capture of one of these pages to see if I can quash the validation errors, but if there is a current version of the forum software somewhere available then it would be very easy to solve this through editing the templates and avoid missing something.
Australia Forum Administrator #30
I don't totally agree with this. For any web browser to say "it makes no claims regarding rendering incorrect code at all", I don't think you would sell, or give away, a single copy.

There must be millions of web pages that have non-complying HTML. Just as an example picked at random, I tried a page from Microsoft's own web site:

http://www.microsoft.com/games/default.aspx

The validation for that failed with 48 errors, including:

"No DOCTYPE found! Attempting validation with XHTML 1.0 Transitional."!

Now if one of Microsoft's main web pages has 48 errors, and bear in mind they make software to generate web pages so they should know what they are doing, what hope does the ordinary developer have?

Web browsers, by their nature, know they are going to get incorrect HTML a lot of the time, and have to try to render them in a reasonably useful and meaningful way.

I am a developer and understand the concept of "behaviour is undefined if you do X", for example if you use a pointer without initialising it, the behaviour is undefined because of the random data that is probably in that memory location.

However, a web browser that simply receives tags out of order, is hardly the same thing as using an uninitialised memory address.

Put it this way, I have been using Firefox for about 3 days now, and am typing this message in using it. In that time I have already had one crash (access violation) which closed all the Firefox windows I had open. I hope they aren't going to try to justify that as "well, you must have got bad HTML so we are entitled to crash". It's a bug, pure and simple.

So is re-rendering a page differently every time you hit refresh.
Amended on Sun 04 Dec 2005 07:01 PM by Nick Gammon
USA #31
In that case then IE and Opera both have the same rerendering bug because I've tested both against your site and seen similar results with the code tag. Undefined behaviour is undefined behaviour, regardless of the browser used.

This obviously does not excuse whatever casued FF to crash for you, and if you sent the Talkback report on it they do monitor those.

I have been using Firefox now since they were version 0.2 and called Phoenix and to date I have not had anything serious come about from an actual release version. One can expect crashes on their alpha or beta lines but the releases have all been rock solid.

Relying on Microsoft as an example of who does things right is laughable at best when it comes to web standards. Even they admit this in their IE7 developer blogs. IE bugs are well known and very frustrating to web developers everywhere.

In any case, I'm still toying with the source capture from this very topic to see what I can come up with. Although as I said before current forum source would help alot :)
USA #32
You know I've never had Firefox ever crash <.<
Australia Forum Administrator #33
Quote:

Relying on Microsoft as an example of who does things right is laughable at best when it comes to web standards.


I know, I am just saying that if Microsoft don't have it right, and they have a huge number of web pages, then there must be an awful lot of "undefined behaviour" around.

I tried:

http://www.apple.com/

3 validation errors.

http://www.php.net/

10 validation errors.

http://www.google.com.au/

41 validation errors.

I would like to fix up my HTML, my point being that "invalid" HTML is somewhat of the rule.

BTW, all of the sites on Samson's signature passed validation, well done! :)

Quote:

Although as I said before current forum source would help alot :)


You are welcome to it, I just need to make sure that it will run, by dumping the database declarations too. Sometimes when I add a new feature it also needs a new field on the database, and without that, you may get errors on select statements etc.
USA #34
I hear ya on the invalid HTML being the rule more than the exception. I don't think in this case that it's the number of validation errors you get, a couple of simple changes to the source capture I did dropped it in half by removing just one font tag. In this case here I think it's mainly the font tags which are causing all the grief. Alot of size=1 and size=-1 but if I recall correctly these are all relative and should be based on something defined but I'm not seeing that, so maybe that's what the browsers keep choking on?

My sites took a great deal of time to fix up, it wasn't easy given the code I started with but if you look carefully even with perfect validation IE still slightly skews one of the div borders on the right side of the afkmud and smaugfuss pages. Validation isn't the cureall, but it goes a long way toward curbing undefined results.
Australia Forum Administrator #35
Well, I'm making progress. My main forum page now validates as HTML 4.01. See what you think. Some pages may not validate, especially those which I did my own HTML in.

Let me know if you find any particularly bad examples. Especially standard "generated" pages, once the problem is fixed, it should be fixed for all instances of it.
USA #36
Did a quick scan of a few random pages, only coming up with one validation failure now on the textarea tags for inputting stuff, like this reply, saying that the "wrap" attribute is not valid. I'd ignore that one though as we also ignore complaints about it with Quicksilver Forums since there is no other method we've found yet to allow our text boxes that need to turn wrapping off to do so without causing serious problems.

Also no longer seeing inconsistent code tag sizes. I think whatever was causing all the various validation problems had something to do with it. Most likely the interaction of the font tags with each other.
Australia Forum Administrator #37
Quote:

The default monospace font in FF is 3 or 4 sizes smaller than for proportional.


Why is this anyway? Is it to annoy people who are trying to mix monospace and proportional fonts on a page? Surely if I want my monospaced font smaller I tell the browser with a "size" tag? Especially as IE doesn't seem to do that.
USA #38
Got me on the monospace font thing. I haven't noticed anything about it until you mentioned it. Perhaps I've just never tried to mix the two and other sites I frequent don't either? Might be something to file in the Firefox bugzilla.