473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
21 86356
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

"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
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
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

[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
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
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
"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
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
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
"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
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
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
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
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
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

"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dlgproc | last post by:
I wanted to display text in a label on a Windows form in a fixed-width font. In C++ Windows API programming I’ve always used: GetStockObject(SYSTEM_FIXED_FONT). Using the following C# code...
1
by: Drew | last post by:
Hey, thanks in advance for helping me out with my problem: I have a datagrid which is embedded in another datagrid. The datagrid is filled directly by a dataset generated from a sql query. So...
3
by: Noozer | last post by:
I need a fast "console" type control. Basically a textbox that uses a fixed width font and can be configured for a specific width and height. I may need to apply colour and double width & height...
0
by: Ken Varn | last post by:
I have a managed C++ assembly in which I need to interact with some 'C' APIs that take fixed size 'C' data blocks. I need to wrap these data blocks into a managed object. It seems like a lot of...
8
by: chrisben | last post by:
Hi, If I am not sure how many items will be in my Hashtable/ArrayList dynamically (multiple threads can add/remove/check the item), however, I can estimate the total number will not exceed...
2
by: neuneudr | last post by:
Hi everybody, I'm scratching my head with a CSS problem. I want to have the following (the two pics have these size for a good reason, the whole point of the page is basically to show these...
3
by: patl | last post by:
Hi all, I am trying to write a terminal emulator using Javascript + AJAX and I need to create an 80x25 table (each cell contains 1 character) in which I can update the contents of each cell...
1
by: kendrick82 | last post by:
Hi, I would like to seek some advise and assistance regarding the following matter as I am new to VB.Net. I'll appreciate any helps render. I am developing a VB application using VB.Net 2003 to...
3
by: jerrygadd | last post by:
Hi can anyone please help? I have a need to make a table of fixed size, containing three rows, where the middle row auto expands to fill the remaining space between the top and bottom rows. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.