This documentation is archived and is not being maintained.

Setting CSS Font Attributes

Visual Studio .NET 2003

Font formatting attributes determine how formatted text will be displayed in Web browsers. You can set preferred font families, font size and color, and whether text is bolded, or italicized, or underlined. You can add font formatting attributes to CSS style rules defined either on an external CSS style sheet or within a <STYLE> block in the <HEAD> portion of your Web page.

To apply a style rule to a particular HTML element in the <BODY> section of your Web page, add a CLASS or ID attribute to the opening tag of the element whose value is the selector for the desired CSS style rule. You also can add CSS font attributes directly to HTML elements that support the STYLE attribute.

Note   If you define a BODY {} style, all of the text on the page that is not formatted by an inline style will be displayed in the style specified.

To prepare to build a CSS font style

  1. Open an external CSS style sheet document for editing, and follow the procedures in the topic Building CSS Styles.

    - or -

    Open a Web page for editing in Design view, and follow the procedures in the topic Inserting CSS Styles from the Document Styles Window.

  2. On the Styles menu, choose Build Style.

    The Style Builder dialog box appears.

  3. Choose Font in the left pane, and select style options.

    The preview area at the bottom of the dialog box updates to illustrate the current settings as you make selections. Corresponding properties and values are added to the CSS style definition.

To choose fonts

  • In Font Name Family, type a font name. Separate font names with commas.

    Click the ellipses (...) button to open the Font Picker, and choose from the Installed Fonts on your own system, or type font names directly in Custom Fonts.

    It is helpful to add more than one font. The user's Web browser then will attempt to match each font choice in the order listed, until it finds a font available on the user's local machine. At the end of your font list, include a category from the Generic Fonts list to provide an if none of the above choice. The resulting font-family list might, for example, read:

    font-family:Verdana, Arial, Helv, Helvetica, sans-serif;
    
    Note   If you choose the System font family from Installed Fonts, the font and formatting applied will vary from user to user, depending upon the default font and formatting settings a user has defined. System fonts are most useful in intranet applications designed for communities of users who share common Web browsers and system configurations.

To choose a font size

  • In Specific Size, type a font size, and select a unit option from the adjacent list.

    You can set a specific, relative, or absolute size for a font. Absolute size makes it possible for you to select one of seven choices that range from XX-Small to XX-Large. Relative size offers a choice between larger and smaller.

To choose a font color

  • Select a color from the Color list, or click the adjacent ellipses (...) button to open the Color Picker dialog box and select additional colors.

To choose font highlighting and effects

  • Choose an option from the Bold list. Absolute Bold applies a specific, fixed level of bold. Relative Bold applies a bold value that is either more or less bold than the current level of bold.
  • Select a Capitalization option.
  • Select a value from the Italics or Small Caps lists.
  • Specify one or more effects.

To complete your style

  • Go from tab to tab in the left pane of the Style Builder dialog box to display further style options that can be added to your style rule.

See Also

Font, Style Builder Dialog Box | Color Picker Dialog Box | Working With CSS Styles | Introduction to Cascading Style Sheets | Building CSS Styles | Adding CSS Style Attributes in Design View | Inserting CSS Styles from the Document Styles Window | Creating an External CSS Style Sheet

Show: