Home > Articles > Web Development > Microsoft Expression Studio

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Formatting Text

Adding text to a page in Expression Web 3 is similar to creating a document in your favorite word processor. Many of the same tools are available.

I'm not going to go into the details of basic text formatting because I'm sure you already understand how to bold and italicize text. Instead, I'll explain how to work with HTML-specific formatting.

How Expression Web 3 Formats Text

Before you start formatting text in your page, you should become familiar with how Expression Web 3 applies formatting. Because Expression Web 3 is designed to create standards-compliant sites, it often uses CSS to apply formatting. How it goes about doing so is based on the CSS Mode setting.

The current CSS Mode setting is displayed using an icon in the Status Bar when a page is open. To adjust the CSS Mode setting, click the CSS Mode icon on the Status Bar and select the desired mode, as shown in Figure 3.3.

Figure 3.3

Figure 3.3 The CSS Mode setting controls how styles are applied and can be adjusted via the Status Bar.

By default, the CSS Mode setting is set to Auto. In this mode, Expression Web 3 will apply formatting using CSS rules that are configured on the CSS tab of the Page Editor Options dialog.

When the CSS Mode setting is Manual, Expression Web 3 will automatically display the Style Application toolbar shown in Figure 3.4. The Style Application toolbar allows you to specify how to apply styles when edits are made.

Figure 3.4

Figure 3.4 You can control how styles are applied by setting the CSS Mode to Manual and using the Style Application toolbar.

When the CSS Mode setting is set to Auto (the default), you are at the mercy of Expression Web 3 when it comes to where CSS styles get defined. In many cases, that's a suitable situation. However, you might want more granular control over where styles are created. For example, you might have a CSS file attached to the current page, and you may want to ensure that all newly created CSS styles are created inside that CSS file.

By setting the CSS Mode setting to Manual, you can use the Style Application toolbar to specify where new styles are created using the Target Rule drop-down shown in Figure 3.4. Based on what is currently selected, the following options are available in the Target Rule drop-down.

  • An Existing CSS Element—If the selected page element already has a CSS class or ID applied to it, you can select the CSS ID or class from the Target Rule drop-down. If you then make modifications to the selected element, Expression Web 3 will modify the CSS class or ID applied to it.
  • Inline Style—If the selected element has an inline style applied to it, selecting Inline Style from the Target Rule drop-down will cause the inline style to be modified when formatting is changed.
  • New Inline Style—Formatting changes will be reflected in a new inline style.
  • New Auto ID—Causes Expression Web 3 to create a new, auto-generated CSS ID for any formatting changes that are applied. Expression Web 3 will create the new CSS ID in an embedded style sheet inside the current page.
  • New Auto Class—Causes Expression Web 3 to create a new, auto-generated CSS class for any formatting changes that are applied. As with the New Auto ID option, the CSS class is created in an embedded style sheet in the current page.
  • Apply New Style—Allows you to create a new style using the New Style dialog. The location for the new style can be specified in the New Style dialog.

Font Families

In a word processing application, the font you apply to text will always be the font the viewer of the document sees. Web pages don't work that way. For you to see text formatted in a particular font on a page, that font must be installed on your machine. If it's not, the browser will substitute a font you have.

It's a good idea to always specify a series of fonts to use and specify a generic font (such as sans-serif and monospace) as the last choice. By doing this, if a visitor to your site doesn't have the first font listed, the browser will attempt to use the next font in the list and so on. You can easily configure fonts in Expression Web 3 by selecting Format, Font to display the Font dialog shown in Figure 3.5. Alternatively, you can use the Font drop-down on the main toolbar.

Figure 3.5

Figure 3.5 The Font dialog lets you easily choose a font family and otherwise modify the appearance of text.

Font Sizes

Font size is one of those things many developers take for granted. Many Web designers say you should always use pixel dimensions (for example, 12 px) for font sizes. In fact, if you want your site to be as user-friendly and accessible as possible, you should use relative font sizes.

When you use the Font Size drop-down on the toolbar or adjust the font size using the Font dialog, Expression Web 3 will automatically use relative font sizes. The following code shows a CSS style that defines a relative font size that will equate to approximately 14-point type:

.mainText {
   font-size: medium;
}

Using relative fonts is a good idea because it gives your site visitor control over the size of the text. When you change the text size in your browser, text that is sized with a relative font size will resize accordingly while text that is sized with an absolute size will remain the same size.

  • + Share This
  • 🔖 Save To Your Account