Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 

Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format



Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

CSS Tip:
Setting Fonts in a SELECT List

by Tom Dahm,
Chief Operations Officer,
NetMechanic, Inc.

  
March 2000
Vol. 3, No. 3
 • HTML Tip
 • CSS Tip
 • Promotion Tip
  

Want to stylize the menus in your HTML forms? Here's a way you can do so in both Netscape and Microsoft browsers.

One of the frustrating things about HTML forms is the lack of control you have over their look-and-feel. Whereas other HTML elements, such as tables and frames, let you set their font, dimensions, and color, it's hard to get the same kind of control over forms.

For example, suppose you want to build a drop-down menu in your page. A drop-down menu is officially known as a SELECT list. Here's the code you might use:

<FORM METHOD=GET ACTION="something">
<SELECT NAME=my_menu>
   <OPTION>Red
   <OPTION>Green
   <OPTION>Blue
</SELECT>
</FORM>

This gives you the menu shown below:

Neither the SELECT nor the OPTION tags let you set the font for your menu, so you have little control over the style or width of your menu. When you're trying to set your page layout, this inability to control the width of the menu can be a real headache.

To get around this problem, you might try wrapping a FONT tag around the SELECT list, like this:

<FORM METHOD=GET ACTION="something">
<FONT FACE="monospace" SIZE="2">
<SELECT NAME=my_menu>
   <OPTION>Red
   <OPTION>Green
   <OPTION>Blue
</SELECT>
</FONT>
</FORM>

This sets the menu's type face to be a monospace font, such as Courier, and sets its size to be "2." Of course, you could use any font name or size you want.

This works well under Netscape browsers, but has no effect at all under Microsoft Internet Explorer.

The solution is to use a Cascading Style Sheet to fix the font under MSIE, like this:

<FORM METHOD=GET ACTION="something">
<FONT FACE="monospace" SIZE="2">
<SELECT NAME=my_menu
  STYLE="font-family : monospace; 
     font-size : 12pt">
  <OPTION>Red
  <OPTION>Green
  <OPTION>Blue
</SELECT>
</FONT>
</FORM>

Now we've created an in-line style by adding the STYLE attribute to the SELECT tag. The style again defines the font to be a monospace type face, and this time defines the size to be 12 points.

Because of Netscape's weak support for style sheets, it doesn't understand this in-line style. However, since it allows the menu to inherit the properties of the FONT tag, we get nearly the same effect. The only difference is that we can define the exact font size we want using the style sheet, whereas Netscape has to use the old, abstract font sizes (1,2,3, etc.). So we end up with a menu that looks nearly identical under both major browsers.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2007,
Keynote NetMechanic
All rights reserved.