CSS & fixed-width fonts

Status
Not open for further replies.

kerriganm

Baseband Member
Messages
57
Anyone know if there's a CSS style for forcing a font to be fixed-width? I find hints that there is, but I can't find the style.
 
List the monospace fonts you'd like, followed by the "monospace" generic font for font-family.
Code:
p.code{
  padding-left: 36px;
  font-family: Courier New, Courier, monospace;
}

Edit: Listing multiple fonts tells the CSS engine to try different fonts from left to right. If one is found, matching stops and its used. If not, it keeps going. For the above code, if the listed fonts aren't found it will look for some generic monospace font. Other last-in-list default fonts are "serif" and "sans-serif", among others.
 
Thanks for the input! I was hoping I could force an attractive non-fixed-width font to act like a fixed-width font, but I guess I'm stuck with butt-ugly fixed-width fonts. *sigh*
 
Well, in that case you can try this:

Code:
p.code{ letter-spacing: 8px; }

Will that work like you want it to? I don't think so. But I'm not sure of the exact look you are going for. You'll get at least as much space between letters as is defined above, but things won't be uniform.

If you really, really want to do what you described above, a 0 spacing 0 padding table would do the trick, but be a pain to set up.
 
I can't use a table- it's a pull-down menu in a form. They wanted some info left aligned and other info right aligned. It could be done in a fixed-width font with a back-end script, but it's ugly. We found a work-around compromise. Thanks for your help!
 
Status
Not open for further replies.
Back
Top Bottom