424,279 Members | 1,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,279 IT Pros & Developers. It's quick & easy.

Which fixed size (width) font are usable/recommendable ?

P: n/a
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines (read: the letters should
have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very ugly.

Is there another font which I can use to display fixed size text ?

Arty

Jul 20 '05 #1
Share this Question
Share on Google+
21 Replies


P: n/a
in post <news:bt*************@news.t-online.com>
Arthur Connor said:
I want to embed some source code lines in an article on a web page.
The font normally used when I declare a <PRE>...</PRE> tag is very ugly.


then change the font your browser uses.

pre,code{font-family:monospace;}

the visitor will get their nice yummy preferred mono font (although it
may not be mono but thats something you need not worry about)
--
brucie
02/January/2004 07:47:32 pm kilo
Jul 20 '05 #2

P: n/a

"brucie" <sh**@bruciesusenetshit.info> wrote in message
news:bt************@ID-117621.news.uni-berlin.de...
in post <news:bt*************@news.t-online.com>
Arthur Connor said:
I want to embed some source code lines in an article on a web page.
The font normally used when I declare a <PRE>...</PRE> tag is very ugly.


then change the font your browser uses.

pre,code{font-family:monospace;}

the visitor will get their nice yummy preferred mono font (although it
may not be mono but thats something you need not worry about)


I'd suggest at least one real font, just in case the browser is going to use
a bad font as the default. Ups your chances.

pre {font-family: 'Courier New', monospace;} is what I usually do.
Jul 20 '05 #3

P: n/a
Arthur Connor wrote:
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines
(read: the letters should have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very
ugly.

Is there another font which I can use to display fixed size text ?


PRE can be defined in CSS - in the head it would be something like
<style type="text/css">
pre
{
font-family:courier, "courier new", monospace;
font-size:1em;
color:#000;
background-color:#fff;
}
</style>

Adjust to taste.

--
PeterMcC
If you feel that any of the above is incorrect,
inappropriate or offensive in any way,
please ignore it and accept my apologies.
Jul 20 '05 #4

P: n/a
in news:bt*************@news.t-online.com,
Arthur Connor typed:
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines
(read: the letters should have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very
ugly.

Is there another font which I can use to display fixed size text ?

Arty

Do you really want to set the font? If you do, then you can simply do
something like this.....

pre {font-family:courier,yukamoondo,serif}


Jul 20 '05 #5

P: n/a

[seen on comp.infosystems.www.authoring.html and cross-posted
to comp.infosystems.www.authoring.stylesheets with f'up set...]

On Fri, 2 Jan 2004, PeterMcC wrote:
Arthur Connor wrote:
Is there another font which I can use to display fixed size text ?


PRE can be defined in CSS - in the head it would be something like
<style type="text/css">
pre
{
font-family:courier, "courier new", monospace;
font-size:1em;
color:#000;
background-color:#fff;
}
</style>


Since the original questioner seems - by the nature of their question
- be only at the very start of understanding the idea of HTML in
conjunction with CSS, I would want to be very careful in offering
unsolicited suggestions about font size and colo(u)r when they were
asking only about a face. Also I'm doubtful about the appropriateness
of proposing the use of an inline stylesheet as the only answer given.

If I answered this question at all, I think I'd want to point to the
benefits of an external stylesheet, not forgetting to stress that this
was only a *proposal* which client agents may action or not, according
to circumstances, and so forth.

Btw, in all my encounters with Courier fonts, the names have been
capitalised (Courier, "Courier New"). The font name matching rules in
CSS are deliberately vague - to accommodate differences between
systems - but I think it's fair to say that specifying the font name
*exactly* will stand the best chance of hitting the mark.

Finally could I mention the potential risks, if a wide character
repertoire is involved, of specifying a font which potentially might
have a smaller repertoire than has the reader's default monospace
font. See the discussion which leads up to this conclusion:
http://ppewww.ph.gla.ac.uk/~flavell/...onts.html#dont

The situation with monospace fonts is particularly fraught, since the
monospace fonts that are routinely distributed with MS OSes seem to
have a quite limited repertoire compared to their proportional fonts
(again, this is discussed on the above-cited page).

best regards
Jul 20 '05 #6

P: n/a
In article <bt*************@news.t-online.com>, ar***@redseven.com
says...
Is there another font which I can use to display fixed size text ?


Any non proportional font will do it. Courier is probably the most
common.

--
Whitecrest Entertainment
www.whitecrestent.com
Jul 20 '05 #7

P: n/a
Arthur Connor wrote:
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines
(read: the letters should have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very
ugly.

Is there another font which I can use to display fixed size text ?


If you use "font-family: monospace" in CSS to define the font in a
pre-element, you leave it up to the user which font is being displayed
as fixed width font. If you still want to define your own font, you can
try Courier New, Courier or Lucida Console, but keep in mind that if the
user doesn't have that font installed, you can't be sure which font will
be displayed!

You can also specify more then one font, and specify "monospace" as a
last option, so if none of the fonts you specified are available, the
user's system will choose the monospace font as set by the user:

for example: font-family: "Lucida Console", Courier, "Courier New",
monospace;

--
Daan Stolp
Jul 20 '05 #8

P: n/a
"Arthur Connor" <ar***@redseven.com> wrote in message
news:bt*************@news.t-online.com...
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines (read: the letters should have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very ugly.

Is there another font which I can use to display fixed size text ?

Arty


Courier New and Lucida Console spring to mind.

--
Ryan Stewart, A1C USAF
805 CSPTS/SCBE
Jul 20 '05 #9

P: n/a
On Fri, 2 Jan 2004, Daan wrote:
If you use "font-family: monospace" in CSS to define the font in a
pre-element, you leave it up to the user which font is being displayed
as fixed width font.


And if you don't specify font-family in the stylesheet, surely
the same thing happens? So what's the point?
Jul 20 '05 #10

P: n/a
ar***@redseven.com (Arthur Connor) wrote:
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines
(read: the letters should have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very
ugly.


The monospace fonts that are most commonly available on people's
browsers are Courier New and Lucida Console. I guess Courier comes
next. They have rather different characteristics - similar shape, but
varying x-height and other properties. Yet, the font that a browser
uses by default might be something still more different,

I would use

<pre><code>...</code></pre>

(just to be logical - it probably has no effect on default rendering)

and the CSS rule

code { font-family: "Courier New", monospace; }

The reason is that Courier New is a reasonable and very widely
available font, usually an improvement over the browser default.
You could reduce the font slightly (say code { font-size: 85%; })
if you think that monospace font is too big as compared with normal
text. The point is that Courier New _is_ rather big in x-height and in
character width.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
Jul 20 '05 #11

P: n/a
"Arthur Connor" <ar***@redseven.com> wrote in message
news:bt*************@news.t-online.com...
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines (read: the letters should have all the same width).

The font normally used when I declare a <PRE>...</PRE> tag is very ugly.

Is there another font which I can use to display fixed size text ?

Arty


There a bunch of fonts out there. Sadly you are limited to what your readers
have installed on their various systems. Unless you can get font embedding
to work and that is something I've not spent enough time with to comment on.

But back to the real word, shouldn't you be marking your source code up with
<code>...</code> instead of <pre>...</pre> as described under W3C's
"Structured Text" recommendations?
http://www.w3.org/TR/REC-html40/struct/text.html
--
John McGaw
[Knoxville, TN, USA]

Return address will not work. Please
reply in group or through my website:
http://johnmcgaw.com

Jul 20 '05 #12

P: n/a
Bob
On Fri, 2 Jan 2004 10:43:03 +0100, ar***@redseven.com (Arthur Connor)
wrote:
I want to embed some source code lines in an article on a web page.
As usual I want to use a fixed sized font for this souce code lines (read: the letters should
have all the same width).
You can get monospaced fonts in HTML using <code>, <tt>, <pre>.
The font normally used when I declare a <PRE>...</PRE> tag is very ugly.
That's because it's a monospaced font. But, since it looks like
most "code", it's probably OK.
Is there another font which I can use to display fixed size text ?


There is no other way to specify fixed fonts that will be reliable
across platforms. You can choose some specific fonts but the odds
of finding them on multiple platforms are low.

Jul 20 '05 #13

P: n/a
In article <Pi*******************************@ppepc56.ph.gla. ac.uk>,
"Alan J. Flavell" <fl*****@ph.gla.ac.uk> wrote:
On Fri, 2 Jan 2004, Daan wrote:
If you use "font-family: monospace" in CSS to define the font in a
pre-element, you leave it up to the user which font is being displayed
as fixed width font.


And if you don't specify font-family in the stylesheet, surely
the same thing happens?


Not in Mozilla. In Mozilla, the UA style sheet has
font-family: -moz-fixed;

The practical difference is with font size.

--
Henri Sivonen
hs******@iki.fi
http://iki.fi/hsivonen/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Jul 20 '05 #14

P: n/a
Arthur Connor wrote:
Is there another font which I can use to display fixed size text ?


See the CodeStyle.org font survey for commonly installed fonts:

http://www.codestyle.org/css/font-family/index.shtml

I would recommend the following CSS:

pre {
font-family: "Lucida Console", monospace;
}

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

Jul 20 '05 #15

P: n/a
Bob
On Sat, 03 Jan 2004 15:00:10 +0000, Toby A Inkster
<Us******************@deadspam.com> wrote:
Arthur Connor wrote:
Is there another font which I can use to display fixed size text ?


See the CodeStyle.org font survey for commonly installed fonts:

http://www.codestyle.org/css/font-family/index.shtml

I would recommend the following CSS:

pre {

}


Nice site.

I might expand that CSS a little:

"Lucida Console", "Andale Mono", "Courier New"
Jul 20 '05 #16

P: n/a
Bob wrote:
Toby A Inkster wrote:
Arthur Connor wrote:
Is there another font which I can use to display fixed size text ?


I would recommend the following CSS:
pre { font-family: "Lucida Console", monospace; }


I might expand that CSS a little:
"Lucida Console", "Andale Mono", "Courier New"


The OP was explicitly trying to avoid Courier! So why specify over the
generic monospace font?

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

Jul 20 '05 #17

P: n/a

"Alan J. Flavell" <fl*****@ph.gla.ac.uk> wrote in message
news:Pi*******************************@ppepc56.ph. gla.ac.uk...
On Fri, 2 Jan 2004, Daan wrote:
If you use "font-family: monospace" in CSS to define the font in a
pre-element, you leave it up to the user which font is being displayed
as fixed width font.


And if you don't specify font-family in the stylesheet, surely
the same thing happens? So what's the point?


Of course, this all presupposes the average user knows how to change their
fonts, or even can in their browser. I can't for the life of me figure out
how to tell IE to use this or that font as say a sans-serif default. Their
only choices are "Web Page" and "Plain text". I guarantee that even if it's
possible, nearly all IE users can't figure it out.

As most of our visitors are stuck with whatever IE chooses for them, it's up
to the author to supply enough reasonable choices in the stylesheet to avoid
IE choosing Wingdings or other nonsense as the default for a family. But
still always end with a generic, just in case.
Jul 20 '05 #18

P: n/a
On Sat, 3 Jan 2004, Neal wrote:
Of course, this all presupposes the average user knows how to change their
fonts, or even can in their browser.
I don't agree. Those kind of users will get the font which their
vendor has prepared for them; there's no "supposition" on my part that
the "average" user will be able to do any different.

Like you: I still have no idea how, as a user, to tell MSIE which
actual font to use as the generic monospace (or any of the other
generic fonts). But MSIE isn't the only browser. For most purposes I
prefer to use a WWW-compatible browser.
As most of our visitors are stuck with whatever IE chooses for them,
They've got just as much choice as I have; if they don't choose to
exercise that choice, they can still have what their vendor picked for
them. Sometimes that produces the wrong results; but in relation to
the current question, the effect seems to me to be purely a cosmetic
detail having little or no impact on the substantive content.
to the author to supply enough reasonable choices in the stylesheet to avoid
IE choosing Wingdings or other nonsense as the default for a family.


Yes, I have seen it do *that* in the past under circumstances that I
never really understood - in which case, it's safer not to interfere
with IE's font face via CSS at all; but I haven't seen it happen in
recent releases.
Jul 20 '05 #19

P: n/a
Toby A Inkster <Us******************@deadspam.com> wrote in
news:pa****************************@goddamn.co.uk:
Bob wrote:
Toby A Inkster wrote:
Arthur Connor wrote:

Is there another font which I can use to display fixed size text ?

I would recommend the following CSS:
pre { font-family: "Lucida Console", monospace; }


I might expand that CSS a little:
"Lucida Console", "Andale Mono", "Courier New"


The OP was explicitly trying to avoid Courier! So why specify over the
generic monospace font?


Whatever.

How about we throw in some more fixed-width fonts :)

"Andale Mono", "Lucida Console", "OCR A Extended", "Fixedsys",
"Terminal", "Courier", monospace;

Added Courier in there because it is slightly different than Courier New
:).

Not sure about the beauty of Terminal and Fixedsys though :).
Jul 20 '05 #20

P: n/a
On Sat, 3 Jan 2004, Henri Sivonen wrote:
"Alan J. Flavell" <fl*****@ph.gla.ac.uk> wrote:
On Fri, 2 Jan 2004, Daan wrote:
If you use "font-family: monospace" in CSS to define the font in a
pre-element, you leave it up to the user which font is being displayed
as fixed width font.


And if you don't specify font-family in the stylesheet, surely
the same thing happens?


Not in Mozilla. In Mozilla, the UA style sheet has
font-family: -moz-fixed;


Thanks for making that point. So now I'm not quite sure what I'd
recommend as best: there seem to be several acceptable answers, none
of them without *some* negative feature, and none of them a clear
winner in the compatibility stakes.

Jul 20 '05 #21

P: n/a
Bob
On Sat, 03 Jan 2004 16:37:28 +0000, Toby A Inkster
<Us******************@deadspam.com> wrote:
Bob wrote:
Toby A Inkster wrote:
Arthur Connor wrote:

Is there another font which I can use to display fixed size text ?

I would recommend the following CSS:
pre { font-family: "Lucida Console", monospace; }


I might expand that CSS a little:
"Lucida Console", "Andale Mono", "Courier New"


The OP was explicitly trying to avoid Courier! So why specify over the
generic monospace font?


The reason I included Courier New is that it is actually a more
attractive font than Courier. Also, it is a last resort at
actually choosing a font instead of just picking up a default.
Jul 20 '05 #22

This discussion thread is closed

Replies have been disabled for this discussion.