Closed Bug 289962 Opened 20 years ago Closed 13 years ago

The default font size for <code> and <pre> in HTML pages is too small.

Categories

(www.mozilla.org :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: wtc, Unassigned)

References

()

Details

I'm working on an HTML page that contains sample C code.
The code is enclosed in either the <code></code> or <pre></pre>
tags.

The URL of the page is
http://www.mozilla.org/projects/security/pki/nss/devel/coding-style.html.

When I view the page in Firefox, I found that the font for
my sample C code is too small.

However, if I view the original source of that page as a local file
(for example, with a file URL like
file:///C:/gila/mozilla-org/html/projects/security/pki/nss/devel/coding-style.html),
the font for my sample C code is just right.

So apparently the www.mozilla.org web site applies some
rule to its web pages that changes of the font size of the
text in <code></code> and <pre></pre> tags.

I also found that in another web page:
http://www.mozilla.org/hacking/mozilla-style-guide.html
the font size for sample C/C++ code is just right.

So apparently it is possible to change the font size,
but I haven't figured out how.  Still, the default font
size should be made right.
You want to add a DOCTYPE to that page similar to the one on the hompage
(mozilla.org). You might also want to read:
 <http://www.mozilla.org/contribute/writing/markup>
 <http://www.mozilla.org/contribute/writing/guidelines>

(For example, use <pre class="code"> or <pre class="example code">, not just <pre>.)
Anne:

Thank you for the tip.  You are right.  Using a DOCTYPE similar to
the one on the hompage (mozilla.org) does the trick.

We were using the DOCTYPE generated by Mozilla Composer before:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

I changed the page to use this DOCTYPE instead:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

Do you know whether it's the "Transitional" or the lack of
"http://www.w3.org/TR/html4/strict.dtd" that caused the font size
problem?  Sorry, I don't know HTML that well.

I am still disappointed that the default font size
for <code> and <pre> doesn't look good.  This is a
recent change because our pages looked good before.
It seems that I need to fix the DOCTYPE in all of our
pages.  I'm wondering if Mozilla Composer should be fixed
to generate a more appropriate DOCTYPE.

See:
 <http://www.mozilla.org/docs/web-developer/quirks/>

In recent versions of NVU you can choose your DOCTYPE to be Strict. However, I
think you want to edit your documents by hand, mostly.
this bug is also present in FireFox. i consider it a bug because setting the
font size in CSS of the pre or code element does not correlate with the rest of
the page. e.g. when using the strict doctype with this css

body
{
font: normal 62% verdana;
}

pre
{
font-size: 100%;
}

the pre text seems to be a lot smaller than the text. here i use verdana as the
scaled font, which is designed to scale well to small sizes so it may be that
the pre size is "correct" strictly logically, however to the naked eye it looks
wrong.

the "solution" in css is to up the pre css font size by almost double, which
creates issues in other browsers
This bug is about Mozilla's Web site's CSS.  comment 4 describes a similar bug
in site's CSS (or at least failing to work around bugs in some of the users fonts).
Assignee: www-mozilla-org → nobody
QA Contact: danielwang → www-mozilla-org
Product: mozilla.org → Websites
Blocks: 521707
The <pre>/<code> font size looks to be alright now. Resolving as WFM.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
Component: www.mozilla.org → General
Product: Websites → www.mozilla.org
You need to log in before you can comment on or make changes to this bug.