Working with Cascading Style Sheets

 < Day Day Up > 



Cascading style sheets (CSS) are used to format Web pages much in the same way traditional style sheets are used to format standard Word documents. The role of cascading style sheets is to present Web page formatting information in a specific place-either at the beginning of an HTML document or in a separate document-in a format that browsers can easily interpret and apply to the associated Web page or pages. Using cascading style sheets provides a convenient way to format several Web pages or a whole Web site. When cascading style sheets are in use, you can change the format of Web pages by making changes to the style sheet information instead of editing individual Web pages.

Because Word automatically creates your source code, you don't actually see that Word creates cascading style sheets. By default, Word uses cascading style sheets if your target browser option is set to Internet Explorer 4 or Netscape Navigator 4. (For more information about configuring your target browser, see "Specifying Target Browser Options".) When Word creates a cascading style sheet, Word embeds the style sheet at the top of each Web page.

In addition to generating cascading style sheet information, you can use Word to attach, remove, and manage cascading style sheets for Web pages. You can also use Word to attach more than one style sheet to a Web page if necessary. For example, you might have one style sheet that's part of a large Web site, such as a style sheet for an international corporation, and another style sheet that defines a smaller group of related pages, such as a style sheet for a regional office. You can then specify which style sheet takes precedence over the other, in case conflicting styles are defined for the same element. When you attach a style sheet to your Web page in Word, the styles in the cascading style sheet will appear in the Styles And Formatting task pane.

Cross-Reference 

For more information about the Styles And Formatting task pane, see Chapter 9, "Using Styles to Increase Your Formatting Power."

Working with Embedded Cascading Style Sheets

If you're familiar with coding HTML source code and cascading style sheets by hand, you might want to make changes directly to a style sheet that's embedded in a Web page. To do so, open the Web page, display the Web page's HTML Source code in the Script Editor (choose View, HTML Source), and then make changes directly to the code. Editing CSS code can come in handy if you want to tweak the code or make a quick change, such as changing the font family used for a style, as shown in Figure 26-21. After you make changes to source code in the Script Editor, you can save the changes, close or minimize the Script Editor, and then view the effects of your changes in the Web page document.

click to expand
Figure 26-21: If you're comfortable editing HTML source code and working with CSS code, you can make changes directly to a Web page's embedded cascading style sheet.

Tip 

For the latest information about CSS standards and sample code, visit the Cascading Style Sheets home page on the World Wide Web Consortium (W3C) Web site at http://www.w3.org/Style/CSS.

Attaching Cascading Style Sheets

If you have a cascading style sheet file, you can attach it to a Web page. Cascading style sheets carry the .css extension. You attach a cascading style sheet to a document the same way you attach a global template or an add-in. Specifically, you must complete the following steps:

  1. Choose Tools, Templates And Add-Ins. The Templates And Add-Ins dialog box appears.

  2. Click the Linked CSS tab, as shown in Figure 26-22.

    click to expand
    Figure 26-22: You can use the Linked CSS Style Sheets dialog box to attach, detach, and prioritize cascading style sheets.

  3. Click the Add button. The Add CSS Link dialog box (which looks very similar to the Open dialog box) appears and displays any cascading style sheet files stored in your Templates folder.

  4. If necessary, navigate to the cascading style sheet you want to add, select it, and then click OK.

  5. To attach multiple style sheets to a document, repeat steps 3 and 4. After you've finished attaching cascading style sheets, click OK. A message box will appear, stating that the style sheet has changed and that you must save and reload the document. To have Word do this for you, click Yes.

After you attach a cascading style sheet to a document, the styles from the cascading style sheet will appear in the Styles And Formatting task pane.

start sidebar
Changing the Order of Cascading Style Sheets

The order of cascading style sheets provides a precedence that determines which styles are applied if two or more style sheets have conflicting settings for the same element. When you move a style sheet up in the list, you assign a higher priority to the style sheet. Likewise, when you move a style sheet down in the list, you assign a lower priority to the style sheet. To configure precedence among style sheets, follow these steps:

  1. Choose Tools, Templates And Add-Ins. The Templates And Add-Ins dialog box appears.

  2. Click the Linked CSS tab.

  3. Select a style sheet in the list, and then click Move Up or Move Down to change the style sheet's precedence.

  4. Click OK to close the Templates And Add-Ins dialog box.

end sidebar

Detaching Cascading Style Sheets

You can detach a cascading style sheet if you want to stop using the cascading style sheet to format a document. To do so, follow these steps:

  1. Choose Tools, Templates And Add-Ins. The Templates And Add-Ins dialog box appears.

  2. Click the Linked CSS tab.

  3. Select the style sheet you want to remove, and then click Remove.

  4. Remove any other style sheets you want to detach, and then click OK when you've finished. A message box will appear, stating that the style sheet has changed and that you must save and reload the document. To have Word do this for you, click Yes.

Keep in mind that when you remove a style sheet from the list, you don't delete the style sheet's file; you simply instruct the current document to stop referring to the style sheet.



 < Day Day Up > 



Microsoft Office Word 2003 Inside Out
Microsoft Office Word 2003 Inside Out (Bpg-Inside Out)
ISBN: 0735615152
EAN: 2147483647
Year: 2005
Pages: 373

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net