Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fixed Width Font in Option

Status
Not open for further replies.

stoolpigeon

Programmer
Aug 1, 2001
309
US
I have a dynamically created <Select> that I build w/PHP.

Each <Option> description is the same length because I pad them with spaces. The problem is I cannot find a way to force the text in the Option to come out fixed width. So even though each element has the same number of characters, spaces are narrower and my lines don't appear the same width to the user.

A similar question was asked last year (I did search first) but I did not see that it was resolved. There was some agreement that formatting text within <option> tags was difficult.

Is there a good solution to this situation?

Thanks,
Ron
 
What you need is a monospace font, which is a non-proportional font, as opposed to a proportional font, which is what most fonts are. This is the same thing that has caused problems with text fields and textareas in Netscape. I used to have a link to some information about it, but I can't find it now.

Anyway, this should work:

select {font-family: monospace; font-size: 12px} or

select {font-family: courier; font-size: 12px}

These are both serif fonts, and will work. There should be some sans-serif monospace fonts out there, but I haven't looked recently.

Good luck,

 
What tnsbuff notes is true but be careful. Although most PC's come equipped with at least 1 monospaced font, there is no guarantee that the user hasn't deleted it or a system just doesn't have such a font. There's always a better way...
 
If there is a better way that someone can explain to me I am all for it.

(I am not new to programming but I am new to HTML- the adjustment is at times irksome.)

Thanks for the suggestions- I will be trying them out.
 
Well, another option is to set the width of your select tag using css, although I'm not sure it's a &quot;better&quot; option.

As is the case with all elements of display on the web, no page is going to display exactly the same on every single user's monitor. That's a given. The best we can do is go for the majority using one or more methods to accommodate as many viewers as possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top