Chapter 12. Creating Styles and Layouts with CSS

Introduction

Cascading Style Sheets are becoming the predominant method of formatting a Web site. A Cascading Style Sheet (CSS) is style information that can be referenced by individual or multiple Web pages. The cascading part of cascading style sheets indicates different style levels and the control each one has over the other. CSS let you separate the content of a Web page from its layout and design. A CSS Web page is an HTML file with links to a CSS file. You can create the two files separately, or you can use CSS Layouts in Expression Web to create and link them.

Expression Web provides several panels and toolbars to help you create and manage CSS. The CSS tools include four tasks panes: Manage Styles, Apply Styles, CSS Properties, and Tag Properties, and two toolbars: Style Application and Style. Expression Web also provides two different Quick Tag tools for working with tags: Quick Tag Selector and Quick Tag Editor. The Quick Tag Selector makes it easy to identify and select page elements, including CSS classes and IDs. The Quick Tag Editor allows you to modify an HTML tag using color coding and IntelliSense support. IntelliSense displays a context-sensitive dropdown list of code choices you can quickly select and insert in Code or Split view.

If you’re having CSS problems, you can use CSS Reports to help identify them. CSS Reports helps you check individual pages or an entire Web site for errors relating to unused styles, undefined classes, mismatched case.

Working with HTML Code

HTML Code

Code view and Split view (upper pane) allow you to view and edit the HTML (HyperText Markup Language) code generated by Expression Web or write your own. The code in these views is indented and color-coded to make it easier to read and follow.

Write Valid Code

When you make code changes, Expression Web checks the code to make sure it’s valid. If the code is invalid, Expression Web adds a wavy red underline to it. If your code has structure problems, Expression Web highlights the code in yellow. To help you enter valid code, Expression Web uses IntelliSense, which provides a pop-up menu with commands. As you type code, IntelliSense recognizes what you’re doing and provides a pop-up menu with valid commands. You can select the command and press Enter or double-click it to insert it.

Use Code Snippets

Instead of retyping the same code on multiple pages, you can reuse a code segment, known as a code snippet. To insert a code snippet in Code or Split view, click to place the insertion point, press Ctrl+Enter, and then select the code snippet you want from the pop-up menu. You can add, delete, or modify code snippets as well as change code formatting and color coding in the Page Editor Options dialog box. To open the dialog box, click the Tools menu, and then click Page Editor Options.

In addition to these tools, you can also right-click a HTML tag to access many helpful tools and commands, including Find Matching Tab, Select Block (of code), and Find Matching Brace.

HTML Tags

An HTML tag is code inserted in a document that specifies how the document, or a portion of the document, should be formatted. HTML defines the structure and layout of a Web document by using a variety of tags and attributes.

Tag Properties

The Tag Properties panel allows you to examine the attributes related to HTML tags. When you select an HTML element in Design or Code view, the properties associated with the selected tag appear in the Tag Properties panel. The Tag Properties panel shows you properties grouped into three categories: attributes, events, and misc (short for miscellaneous).

An attribute defines the behavior of a tag. You can have more than one attribute for a tag. In the following example, the hyperlink is defined using the <a> tag and the attribute dis defined using the href:

<a href="http//www.perspection.com">Perspection
Web Site</a>

An event is an attribute that is triggered by an event and misc is any non standards-compliant attribute.

Quick Tag Tools

Expression Web provides two different Quick Tag tools: Quick Tag Selector and Quick Tag Editor. The Quick Tag Selector makes it easy to identify and select page elements, including CSS classes and IDs. The Quick Tag Editor allows you to modify an HTML tag using color coding and IntelliSense support.

Understanding CSS Styles and Layouts

Cascading Style Sheets

Cascading Style Sheets (CSS) are becoming the predominant method of formatting a Web site. CSS let you separate the content of a Web page from its layout and design. The separation allows you to display Web content on individual or multiple Web pages with different size computer monitors and other devices, such as PDAs and cell phones.

A CSS contains style definitions, called Selectors, which are the HTML components linked to a specialized list of style properties and values. A selector is followed by those properties and values. For example, h1 {font-size: x-large; color: green}, h2 {font-size: large; color: blue). h1 and h2 are selectors that modify the formatting properties of standard HTML tags.

There are three types of Cascading Style Sheets in Expression Web: external (for multiple pages in the same file), internal or embedded (for individual Web pages), and inline (for individual elements), which you create when you apply a style directly to an item using the Apply Styles panel. An external CSS file uses a .css file extension. The cascading part of cascading style sheets indicates different style levels and the control each one has over the other. The cascading control starts at the lowest level and works its way up: inline, internal, and external. If an inline style is applied to an element, it takes control. If no inline style is applied, then an internal style sheet takes control. If no inline or internal style is applied, then an external style sheet takes control. An inline style is applied to individual elements using tags, such as <p> and </p>. An internal style sheet is applied to an entire page. The coding appears at the top of the page between <head> and </head>. An external sheet links to a file where all the code styles are located. Since the styles are external, you can apply them to multiple files.

CSS allows you to create three different styles: tag-based, class-based, and ID-based. Tag-based styles apply to a specific HTML element, such as paragraph <p> or any of the headings <h1> through <h6>. Class-based styles are not associated with an HTML element, which means you can apply them multiple times to the same page. ID-based styles are similar to Class-based styles, except they are only to be applied once per Web page.

CSS Layouts

CSS Layouts depend on two things working together: div tags (short for page divisions) and ID-based styles. ID-based styles, unlike the element- or class-based styles, can only be used once per Web page, which makes them good for styling navigation bars, banners, layout columns, and footers.

CSS Tools

Expression Web provides several panels and toolbars to help you create and manage CSS. The CSS tools include four tasks panes: Manage Styles, Apply Styles, CSS Properties, and Tag Properties, and two toolbars: Style Application and Style. The Manage Styles panel allows you to create and organize styles, while the Apply Styles panel makes it easy to preview and apply styles. The CSS Properties panel provides several ways to sort through your CSS properties, which includes CSS tags, cascading styles, and CSS rules. The Tag Properties panel displays HTML tag properties for a selected HTML element in Design or Code view and allows you set individual tag attributes. If you prefer using toolbars, you can use the Style Application toolbar to build your CSS manually, or the Style toolbar to apply classes and IDs.

Inserting Common HTML Tags

You can insert commonly used HTML tags into a page by using the HTML submenu on the Insert menu or dragging a control from the Toolbox. The common HTML tags include <div>, <span>, Break, Horizontal Line, Image, Inline Frame, Layer, and Paragraph. When you insert the Break tag from the Toolbox, a single break line is inserted into the page. However, when you insert the Break tag from the Insert menu, the Break dialog box appears, asking you to select an option to insert a normal line or clear the left, right, or both margins.

Insert Common HTML Tags from the Toolbox Panel

  1. Insert Common HTML Tags from the Toolbox Panel Open and display the Web page you want to use.

  2. Insert Common HTML Tags from the Toolbox Panel Expand the Tags category in the Toolbox panel.

  3. Insert Common HTML Tags from the Toolbox Panel Click to place the cursor in Design view where you want to place the HTML tag.

  4. Insert Common HTML Tags from the Toolbox Panel Drag the HTML tag to your Web page in Code or Design view where you want to insert it.

    • <div>. Defines a section of a page. Tag: <div>

    • <span>. Defines a portion of a page. Tag: <span>

    • Break. Inserts a line break to create white space. Tag: <br>

    • Horizontal Line. Inserts a horizontal line. Tag: <hr>

    • Image. Inserts an image placeholder. Tag: <img scr=“” />

    • Inline Frame. Inserts an inline frame. Tag: <iframe id=“I1” name=“I1”>

    • Layer. Inserts a placeholder object that is absolutely positioned. Tag: <div id=“layer” style=“position: absolute”>

    • Paragraph. Inserts a paragraph on a page. Tag: <p>

    Paragraph.

Insert Common HTML Tags from the Insert Menu

  1. Insert Common HTML Tags from the Insert Menu Open and display the Web page you want to use in Design view.

  2. Insert Common HTML Tags from the Insert Menu Click to place the cursor in Code or Design view where you want to place the HTML tag.

  3. Insert Common HTML Tags from the Insert Menu Click the Insert menu, and then point to HTML.

  4. Insert Common HTML Tags from the Insert Menu Select the tag you want on the HTML submenu.

    Insert Common HTML Tags from the Insert Menu
  5. Insert Common HTML Tags from the Insert Menu If you selected the Break command, specify the options you want, and then click OK.

    • Normal line break. Inserts a default line break.

    • Clear left margin. Begins the next line at the nearest line below any items in the left margin.

    • Clear right margin. Begins the next line at the nearest line below any items in the right margin.

    • Clear both margins. Begins the next line at the nearest line below any items in both margins.

    Clear both margins.

Did You Know?

You can format a horizontal line. In Design view, select the line, click the Format menu, click Properties, specify width and height, alignment, and color, and then click OK.

Using Tag Tools

The Tag Properties panel displays HTML tag properties for a selected HTML element in Design or Code view. To display the tag properties, you select the element in Design view or click in the HTML tag in Code view. Each property in the panel displays an icon in the left column that indicates the property type. A finger pointing to a page indicates an attribute and a lighting bolt indicates an event. If a property name appears in bolded blue text, the property is set.

Insert Tags and Comments

  1. Insert Tags and Comments Open and display the Web page you want to use.

  2. Insert Tags and Comments Click the Code or Split button, and then click to place the insertion point where you want.

  3. Insert Tags and Comments To insert tag brackets or comments, click the Edit menu, point to Code View, and then click Insert Start Tag, Insert End Tag, Insert HTML Comment, or Insert CSS Comment (New!).

  4. Insert Tags and Comments To insert common HTML tags, click the plus sign (+) next to Tags in the Toolbox, and then drag or double-click the tag you want.

    Insert Tags and Comments

Show Tag Properties

  1. Show Tag Properties Open and display the Web page you want to use.

  2. Show Tag Properties Click the Panels menu, and then click Tag Properties to display the panel.

  3. Show Tag Properties Select the element in Design view or click in the HTML tag in Code view that you want to view tag properties.

  4. Show Tag Properties Click the plus sign (+) next to the category to want to view: Attributes, Events, or Misc.

    Show Tag Properties

Change the Tag Properties Panel Display

  1. Change the Tag Properties Panel Display Open and display the Web page you want to use.

  2. Change the Tag Properties Panel Display Click the Panels menu, and then click Tag Properties to display the panel.

  3. Change the Tag Properties Panel Display Select the element in Design view or click in the HTML tag in Code view that you want to view tag properties.

  4. Change the Tag Properties Panel Display Click any of the following buttons at the top of the panel.

    • Show Categories List button. Click to display by category as attributes, events, and misc.

      Show Categories List button.
    • Show Alphabetized List button. Click to display alphabetically.

      Show Alphabetized List button.
    • Show Set Properties on Top button. Click to display specified properties at the top of the list.

      Show Set Properties on Top button.

Timesaver

Click the Show Alphabetized List and Show Set Properties on Top buttons to display all set properties at the top.

Setting Tag Attributes

You set tag attributes in the Tag Properties panel. The tag properties that appear in the Tag Properties panel differ depending on the selected element. To set a tag property, select the element in Design view or the tag in Code view you want to change, click the attribute you want in the Tag Properties panel you want to change, and then enter, select, or edit the value box next to it. Some attributes provide a drop-down menu to select a value, while others require certain value types. For other attributes, you can add any text you want, such as the alt attribute for an <img> tag, which provides text for pictures, so the visually impaired can read the text in a ScreenTip. If you are more comfortable using dialog boxes, you can click the Show Tag Properties button at the top of the panel to display a dialog box with the attributes.

Set Tag Attributes

  1. Set Tag Attributes Open and display the Web page you want to use.

  2. Set Tag Attributes Click the Panels menu, and then click Tag Properties to display the panel.

  3. Set Tag Attributes Select the element in Design view or click in the HTML tag in Code view that you want to view tag properties.

  4. Set Tag Attributes Click the plus sign (+) next to the category to want to view: Attributes, Events, or Misc.

  5. Set Tag Attributes To change attributes in the panel, click the value box to the right of the attribute, and then change the value.

  6. Set Tag Attributes Click the Show Tag Properties button at the top of the panel.

    Set Tag Attributes
  7. Set Tag Attributes View the properties, and then make any changes you want.

  8. Set Tag Attributes Click OK.???

    Set Tag Attributes

Using the Quick Tag Selector

Expression Web provides two different Quick Tag tools: Quick Tag Selector and Quick Tag Editor. The Quick Tag Selector makes it easy to identify and select page elements, including CSS classes and IDs. The Quick Tag Selector appears under the tabs in the Editing window. You can use Quick Tag Selector in any view. However, Split view allows you to quickly view and select page elements (Design view) and code elements (Code view) without having to switch.

Use the Quick Tag Selector

  1. Use the Quick Tag Selector Open and display the Web page you want to use.

  2. Use the Quick Tag Selector Click the View menu, and then click Quick Tag Selector to display it under the tabs in the Editing window.

  3. Use the Quick Tag Selector Do any of the following:

    • Point to a tag selector. Highlights the element with a border. Also, displays the tag selector arrow.

    • Click a tag selector. Selects the element or code.

    • Click a tag selector arrow. Point to a tag selector to display the arrow. Displays a menu where you can perform actions on the selected tag. Click Select Tag to select the element or code, or click Select Tag Contents to select only the contents of the tag, not the tag itself.

    Click a tag selector arrow.

Using the Quick Tag Editor

The Quick Tag Editor allows you to modify an HTML tag using color coding and IntelliSense support. In Code view, you see all the HTML code for a given page or element. Sometimes it’s hard to figure out exactly what you want to change. The Quick Tag Editor allows you to easily isolate a specific tag, where you can make changes. You can access the Quick Tag Editor by clicking a tag selector arrow or right-clicking a tag selector, and then selecting one of the following commands on the shortcut menu: Edit Tag, Insert HTML, or Wrap Tag. Other commands on the shortcut menu allow you to remove tags, change CSS positioning, and modify tag properties.

Use the Quick Tag Editor

  1. Use the Quick Tag Editor Open and display the Web page you want to use.

  2. Use the Quick Tag Editor Click the View menu, and then click Quick Tag Selector to display it under the tabs.

  3. Use the Quick Tag Editor Right-click the tag selector or click the tag selector arrow you want to modify.

    • You can also click the Edit menu, and then point to Code View.

  4. Use the Quick Tag Editor Click the command on the shortcut menu you want. Each one displays the Quick Tag Editor dialog box.

    Use the Quick Tag Editor

    Timesaver

    Press Ctrl+Q.

    • Edit Tag. Edit the HTML for the selected tag.

    • Insert HTML. Enter HTML code, which is inserted on the page. The HTML code appears at the insert point or before a selected element.

    • Wrap Tag. Enter HTML code, which wraps the selected tag.

  5. Wrap Tag. Make the changes you want in the edit box.

  6. Wrap Tag. Click the green checkmark button or press Enter to accept your changes, or click the red X to cancel your changes.

    Wrap Tag.

Using CSS Tools

Expression Web provides several panels and toolbars to help you create and manage CSS. The CSS tools include four panels: Manage Styles, Apply Styles, CSS Properties, and Tag Properties, and two toolbars: Style Application and Style. The Manage Styles panel allows you to create and organize styles, while the Apply Styles panel makes it easy to preview and apply styles. The CSS Properties panel provides several ways to sort through your CSS properties, which includes CSS tags, cascading styles, and CSS rules. If you prefer using toolbars, you can use the Style Application toolbar to build your CSS manually, or the Style toolbar to apply classes and IDs.

Use CSS Tools

  1. Use CSS Tools Open and display the Web page you want to use.

  2. Use CSS Tools Click the Panels menu, and then select the following panels: Manage Styles, Apply Styles, CSS Properties, and Tag Properties.

    Use CSS Tools
    Use CSS Tools
    Use CSS Tools
    Use CSS Tools

    The Manage and Apply Styles panels appear on separate tabs in the lower right panel group. The CSS and Tag Properties panels appear on separate tabs in the lower left panel group.

  3. Use CSS Tools Click the View menu, point to Toolbars, and then click Style Application and Styles to display them.

Using IntelliSense

In Code view, IntelliSense displays a context-sensitive dropdown list of choices as you enter code. From the dropdown list, you can quickly select the code item you want to use. You can customize the way IntelliSense works by using the IntelliSense tab in the Page Editor Options dialog box. You can set options to disable shortcut menus and inserting tags, quotes, and braces, and to disable code hyperlinks. By default, all check boxes are selected.

Use IntelliSense

  1. Use IntelliSense Open and display the Web page you want to use.

  2. Use IntelliSense Click the Code or Split button, and then click to place the insertion point where you want to edit the code.

  3. Use IntelliSense Click the Edit menu, point to IntelliSense.

  4. Use IntelliSense Click the command on the submenu you want:

    • List Members. Displays a shortcut menu of valid tag properties.

    • Parameter Info. Displays a ScreenTip that lists valid script parameters.

    • Complete Word. Use to complete the insertion of a selected item.

    • List Code Snippets. Displays the list of code snippets in a dropdown list; you can also press Ctrl+Enter.

    List Code Snippets.

Set IntelliSense Options

  1. Set IntelliSense Options Click the Tools menu, and then click Page Editor Options.

  2. Set IntelliSense Options Click the IntelliSense tab.

  3. Set IntelliSense Options Select the IntelliSense options for CSS that you want in the following categories:

    • Auto Popup. Displays a shortcut menus for statement completion and display ScreenTips.

    • Auto Insert. Automatically inserts the right curly brace (}) that ends a style declaration.

    • Code Hyperlinks. Enables the ability to go to the class-based styles by Ctrl+clicking.

    Code Hyperlinks.
  4. Code Hyperlinks. Click the Authoring tab.

  5. Code Hyperlinks. To set the CSS schema version for IntelliSense, click the Schema version list arrow, and then select the schema version you want.

  6. Code Hyperlinks. Click OK.

    Code Hyperlinks.

Creating Tag-based Styles

A tag-based (also known as element-based) style applies the defined style to every instance of a selected HTML element. When you create a style for a defined tag element (known as a Selector), such as a header <h1> through <h6>, paragraph <p>, or hyperlink <a:link>, it’s applied to every instance of the defined tag on the page (internal) or site (external). After you define the styles you want, the style appears in the Manage Styles tab under the elements category.

Create a Tag-based Style

  1. Create a Tag-based Style Open and display the Web page you want to use.

  2. Create a Tag-based Style Click the New Style button in the Manage Styles or Apply Styles tab.

    Create a Tag-based Style
  3. Create a Tag-based Style Click the Selector list arrow, and then select the type of style you want.

    The Define in box displays Current page by default.

  4. Create a Tag-based Style Select the Categories and make changes to set the appearance of the style you want.

  5. Create a Tag-based Style Select or clear the Apply new style to document selection check box.

  6. Create a Tag-based Style Click OK.

    Create a Tag-based Style

    The Manage Styles tab adds the style to the elements category.

Did You Know?

You can covert a class-based style to an tag-based style. Right-click the class-based style, click Modify Style, click the Selector list arrow, select the element you want to style, and then click OK.

Creating Class-based Styles

Instead of applying a style to a specific element, such as a header, paragraph, or hyperlink, a class-based style can be applied to anything you want to define. This flexibility allows you to create custom styles for your specific purposes. For example, you can create a style called .companyname, which formats the company name with our custom look. You get to decide on the name of the style; it’s best to name styles based on their function, so you can easily identify them in the Styles list. Avoid using numbers at the beginning of a style name. Class-based styles start with a dot (.) to preserve class-based syntax.

Create a Class-based Style

  1. Create a Class-based Style Open and display the Web page you want to use.

  2. Create a Class-based Style Click the New Style button in the Manage Styles or Apply Styles tab.

    Create a Class-based Style

    A default name, .newStyle1, appears selected (without the period at the beginning) in the Selector box.

  3. Create a Class-based Style Type the name you want for the class-based style.

  4. Create a Class-based Style Select the Categories and make changes to set the appearance of the style you want.

  5. Create a Class-based Style Select or clear the Apply new style to document selection check box.

  6. Create a Class-based Style Click OK.

    Create a Class-based Style

    The Manage Styles tab adds the style to the elements category.

Did You Know?

You can rename a class-based style. In the Apply Styles or Manage Styles panel, right-click the class-based style you want to rename, click Rename class “name,” type a new name, and then click OK.

Creating Inline Styles

An inline style allows you to apply formatting directly to an element. An inline style is like an exception to the rule. It’s alright to do every so often. However, it’s not a good practice. It can cause formatting problems when you apply an internal or external style sheet. An inline style doesn’t appear in the Manage Styles tab like the tag- and class-based styles. In the CSS Properties panel, the style is identified by type, inline.

Create an Inline Style

  1. Create an Inline Style Open and display the Web page you want to use.

  2. Create an Inline Style Click in the paragraph or block you want to style.

  3. Create an Inline Style Click the New Style button in the Manage Styles or Apply Styles tab.

    Create an Inline Style
  4. Create an Inline Style Click the Selector list arrow, and then click (inline style).

  5. Create an Inline Style Select the Categories and make changes to set the appearance of the style you want.

  6. Create an Inline Style Click OK.

    Create an Inline Style

    The CSS Properties panel displays <inline style> as the applied rule.

Did You Know?

An inline style is different than an inline element. An inline element, such as <em> emphasized </em>, is applied only to a few characters in a paragraph.

Working with Styles

Instead of creating a new style every time you need one, you can also copy an existing one that is close to the style you want, and then modify it to become the one you want. If you mistakenly apply a style to an element and decided you don’t like it, you can remove the style from the element without deleting the style itself. However, if you want to permanently delete a style, you can certainly do it.

Work with Styles

  1. Work with Styles Open and display the Web page you want to use.

  2. Work with Styles Click in the paragraph or block you want to style.

    • Copy and Change a Style. Right-click the style you want to copy in the Manage Styles tab, click New Style Copy, enter a new name in the Selector box, make any changes you want, and then click OK.

      Copy and Change a Style.
    • Modify a Style. Right-click the style you want to modify in the Manage Styles tab, click Modify Style, make any changes you want, and then click OK.

    • Remove a Style. Select the element with the style, and then click the Clear Style button in the Apply Styles tab.

      Remove a Style.
    • Delete a Style. Right-click the style you want to delete, click Delete, and then click Yes to confirm.

    • Sort and Filter Styles. Click the Options button, and then click one of the sorting or filtering commands, such as Categorize By Order, or Show Styles Used In Current Page.

    Sort and Filter Styles.

Creating and Attaching Style Sheets

Cascading Style Sheets are becoming the predominant method of formatting a Web site. A Cascading Style Sheet (CSS) is style information that can be referenced by individual or multiple Web pages. A CSS contains style definitions, called Selectors, which are the HTML components linked to a specialized list of style properties and values. A selector is followed by those properties and values. There are three types of Cascading Style Sheets: external (for multiple pages in the same file), internal or embedded (for individual Web pages), and the rarely-used inline (for individual items). An external CSS file uses a .css file extension. After you create a style sheet, you can attach it to Web pages. If you no longer need a style sheet attached to a Web page, you can detach it.

Create an External Cascading Style Sheet

  1. Create an External Cascading Style Sheet Click the Web Site tab for the site in which you want a new page.

  2. Create an External Cascading Style Sheet Click the New button arrow on the Common toolbar, and then click Page.

  3. Create an External Cascading Style Sheet In the left pane, click General.

  4. Create an External Cascading Style Sheet Click CSS.

  5. Create an External Cascading Style Sheet Click OK.

    Create an External Cascading Style Sheet

    A blank, untitled CSS file opens in the Editing window.

  6. Create an External Cascading Style Sheet Click the Save button on the Common toolbar.

  7. Create an External Cascading Style Sheet Type a descriptive name for the CSS file.

  8. Create an External Cascading Style Sheet Click the Save as type list arrow, and then click CSS Files.

  9. Create an External Cascading Style Sheet Click Save.

    Create an External Cascading Style Sheet

Attach a Cascading Style Sheet to a Web Page

  1. Attach a Cascading Style Sheet to a Web Page Open and display the Web page(s) to which you want to attach an existing external style sheet.

    Timesaver

    If the style sheet is located in the same Web site, drag it from the Folder List onto the Web page.

  2. Timesaver Click the Attach Style Sheet button in the Apply Styles or Manage Styles panel.

    Timesaver
  3. Timesaver Type the location and CSS file name, or click Browse to locate and select the CSS file.

  4. Timesaver Click the All HTML pages or Current page option.

  5. Timesaver Click the Link or Import option.

  6. Timesaver Click OK.

    Timesaver

Did You Know?

You can move internal styles to an external style sheet. Attach the external style sheet to the current page, open the Manage Styles tab, select the internal styles you want to move, and then drag them onto the external style sheet’s name. The styles are moved to the external style sheet and are no longer in the internal style sheet.

You can detach an external style sheet from a page. Open the page from which you want to detach an external style sheet, right-click the external style sheet in the Manage Styles tab, and then click Remove Link.

Using Rulers and Grid

You can use rulers and a visible layout grid in Design view. Turning on the visible grid makes it easier to create, modify, and align elements of all types. Within the Page Editor Options dialog box, you can select from a variety of options, such as ruler and grid measurement units and the display grid spacing and line color. To align several elements to a grid, you first turn Snap to Grid on. Then you can drag the elements to align them to the grid.

Show or Hide Rulers and Grid

  1. Show or Hide Rulers and Grid Click the View menu, and then point to Ruler and Grid.

  2. Show or Hide Rulers and Grid Click Show Ruler or Show Grid.

  3. Show or Hide Rulers and Grid To have objects snap to grid, click the View menu, point to Ruler and Grid, and then click Snap to Grid.

    Show or Hide Rulers and Grid
  4. Show or Hide Rulers and Grid To hide or turn the options off, choose the commands again.

Set Ruler and Grid Options

  1. Set Ruler and Grid Options Click the View menu, point to Ruler and Grid, and then click Configure.

  2. Set Ruler and Grid Options Click the Ruler and Grid Units list arrow, and then select a measurement.

  3. Set Ruler and Grid Options Select the spacing, line style, and line color for the display grid.

  4. Set Ruler and Grid Options Specify the spacing you want for the snapping grid.

  5. Set Ruler and Grid Options Click OK.

    Set Ruler and Grid Options

Setting Position Properties

Positioning Properties

When you’re working with CSS, you can display elements on a page from top-to-bottom using five positioning properties: absolute, fixed, relative, static, and inherit.

Absolute

An absolute positioned element is placed in relation to the page’s left, top corner. You can position the element anywhere on a page; it’s not confined to a specific place.

Fixed

A fixed positioned element is placed in relation to the browsers window rather than the page or other elements. If you scroll the browser window, the element stays in the same place.

Relative

A relatively positioned element remains part of the placement on the page in relation to the page’s code. When you move a relatively positioned element, its position changes relative to its normal spot in the code.

Static

A static positioned element stays inline (top, bottom) with other elements.

Inherit

An element inherits the positioning of the enclosing parent element.

Floating Properties

Floating properties work similarly to the wrapping styles that control how text flows around images. You can select four floating positions: Left, None, Right, and Inherit. Left allows other elements to flow down its right side. None causes no wrap. The element stays in place and no other elements wrap around it. Right allows other elements to flow down its left side. Inherit uses the float settings of its enclosed parent element.

Clearing Properties

Clearing properties work in relation to Floating properties. You can select five floating positions: Both, Left, None, Right, and Inherit. Both blocks floats on both sides. Left blocks other elements from floating to its left. None causes no floating. The element stays in place and no other elements wrap around it. Right block other elements from floating to its right. Inherit uses the clear setting of its enclosed parent element.

Setting Position Properties

The easiest way to set positioning properties for selected elements is to use the Positioning toolbar, which provides all the positioning options in one place. To display the Positioning toolbar, click the View menu, point to Toolbars, and then click Positioning. Another way to set position properties is to use the CSS Properties tab. Click the Panels menu, and then click CSS Properties to display it. In the properties list, click the box to the right of the properties position, float, and clear to select the option you want. If you want to change positioning properties for a style, right-click the style in the Manage Styles tab, click Modify Styles, click the Position category, make the changes you want, and then click OK.

Setting Position Properties

Creating a CSS Layout

Cascading Style Sheets (CSS) provide a formatting template for Web page elements. Instead of formatting individual elements, which can be time consuming, you can change and apply a CSS to make the changes you want for the entire Web site. CSS allows you to separate your content from your formatting. Using CSS also simplifies and reduces the HTML code, which speeds up download times. A CSS page is an HTML file with links to a CSS file. You can create the two files separately, or you can use CSS Layouts in Expression Web to create and link them.

Create a CSS Layout Page

  1. Create a CSS Layout Page Click the Web Site tab for the site in which you want a new page.

  2. Create a CSS Layout Page Click the New button arrow on the Common toolbar, and then click Page.

  3. Create a CSS Layout Page In the left pane, click CSS Layouts.

  4. Create a CSS Layout Page Click the type of CSS layout you want.

  5. Create a CSS Layout Page Click OK.

    Create a CSS Layout Page

    A blank, untitled HTML Web page appears along with a related untitled CSS-based page.

  6. Create a CSS Layout Page Click the File menu, and then click Save All.

  7. Create a CSS Layout Page In the Save As dialog box, name and save the HTML page and its related external CSS file.

  8. Create a CSS Layout Page Add content to the different layout sections.

    Create a CSS Layout Page
  9. Create a CSS Layout Page To change a layout, right-click the style you want to modify in the Manage Styles tab, click Modify Style, make the changes you want to the Box, Position, and Layout, and then click OK.

    In the Modify Styles dialog box, boldface categories have property values already set.

  10. Create a CSS Layout Page Click the File menu, and then click Save All.

Creating Contextual Selectors

A contextual selector allows you to create styles for different situations. If you want to create a special paragraph style for a main header, you can create a contextual selector to perform the task. With contextual selectors, you can create contextual ID-based styles that only appear when particular tags are used in specific divisions. If you want to use the contextual selector on multiple pages, you can move the contextual selector style to an external style sheet.

Create Contextual Selector

  1. Create Contextual Selector Open and display the Web page to which you want to create a contextual selector style.

  2. Create Contextual Selector Click the New Style button in the Manage Styles tab.

  3. Create Contextual Selector Select the provided selector name including the period, and then type a contextual selector name using the following format:

    #div_name(space)class_name. For example, #page_content p, where p is the paragraph style.

  4. Create Contextual Selector Select the Categories and make changes to set the appearance of the style you want.

  5. Create Contextual Selector Click Apply to view the changes, make any adjustments, and then click OK.

    Create Contextual Selector

    The new contextual style is applied in the appropriate situations and the contextual ID-based style is listed in the Manage Styles tab.

  6. Create Contextual Selector Click the File menu, and then click Save All.

    Create Contextual Selector

Creating a CSS Layout from Scratch

If the CSS pre-built layouts don’t provide exactly what you need, you may want to create a CSS layout from scratch. It’s a two step process: (1) create ID-based styles for each division, (2) insert the divisions, or divs (<div>), and then pairs them with the ID-based styles. You can insert the divs in any order. However, placing them in top to bottom order as they appear on the page helps display the page better on nonCSS browsers. After you insert the divs, you can pair them with ID styles using the Tag Properties panel.

Create ID Styles for a CSS Layout

  1. Create ID Styles for a CSS Layout Click the Web Site tab for the site in which you want a new page.

  2. Create ID Styles for a CSS Layout Click the New button arrow on the Common toolbar, and then click HTML.

  3. Create ID Styles for a CSS Layout Click the New button arrow on the Common toolbar, and then click CSS.

  4. Create ID Styles for a CSS Layout Use the Save button on the Common toolbar to name and save the HTML page and its related external CSS file.

  5. Create ID Styles for a CSS Layout Display the HTML file.

  6. Create ID Styles for a CSS Layout Click the Attach Style Sheet button in the Manage Styles tab.

  7. Create ID Styles for a CSS Layout Specify the CSS file and options you want, and then click OK.

  8. Create ID Styles for a CSS Layout Click New Style in the Manage Styles tab.

    Create ID Styles for a CSS Layout
  9. Create ID Styles for a CSS Layout Delete the Selector, and then type the division name. For example, #container.

  10. Create ID Styles for a CSS Layout Click the Define in list arrow, click Existing style sheet, and then click Browse to select the CSS file. For example, CSS_Scratch.css.

  11. Create ID Styles for a CSS Layout Set the position category to specify a position property, and then click OK.

    Create ID Styles for a CSS Layout
  12. Create ID Styles for a CSS Layout Click the File menu, and then click Save All.

Insert div Tags and Pair with ID Styles

  1. Insert div Tags and Pair with ID Styles Open and display the HTML page with the ID styles for a CSS layout.

  2. Insert div Tags and Pair with ID Styles Click in the HTML page where you want to insert a div tag.

  3. Insert div Tags and Pair with ID Styles Click the Insert menu, point to HTML, and then click <div>.

    • You can also double-click <div> in the Toolbox panel.

    An empty division, marked by a dotted border appears across the top of the page.

  4. Insert div Tags and Pair with ID Styles Click the box for the <div> in Design view or click in the <div> tag in Code view to select it.

    • Changes in Code view don’t appear in Design view until you press F5 to refresh the screen.

  5. Insert div Tags and Pair with ID Styles Click the Tag Properties tab in the panel.

  6. Insert div Tags and Pair with ID Styles Click the blank column to the right of ID, click container from the list, and then press Enter.

    A list of the previously created IDs appears in the list. The container ID is applied to the div tag. This connects the CSS and HTML together.

  7. Insert div Tags and Pair with ID Styles Click in the container div and repeat steps 3 through 6 to insert and ID the next division for your page.

  8. Insert div Tags and Pair with ID Styles Click the File menu, and then click Save All.

    Insert div Tags and Pair with ID Styles

Checking for CSS Problems

Expression Web can help to identify CSS problems using CSS Reports. CSS Reports allows you to check individual pages or an entire Web site for errors relating to unused styles, undefined classes, mismatched case. In addition, CSS Reports also show how CSS is used in a page; it checks the usage of class selectors, ID selectors, and element selectors. After you check for CSS problems, the results appear in the CSS Reports panel, where you can review styles and fix any problems.

Check for CSS Errors

  1. Check for CSS Errors Click the Tools menu, and then click CSS Reports.

  2. Check for CSS Errors Click the Errors tab.

  3. Check for CSS Errors Click the option to specify which pages you want to search.

  4. Check for CSS Errors Select or clear the Check for check boxes you want to include or exclude.

    • Unused Styles. Shows styles not used in the style sheet.

    • Undefined Classes. Shows styles not defined, yet still used.

    • Mismatched Case. Shows mismatches in case between a CSS class or ID in a page and the case used in a style sheet.

  5. Mismatched Case. Click Check.

    Mismatched Case.

    The Accessibility panel opens.

  6. Mismatched Case. To correct a problem, double-click the entry to open the page, where you can correct the highlighted code.

  7. Mismatched Case. To sort or filter information in the panel, click a column header, or click the column list arrow, and then click a filter or Custom to use AutoFilter.

  8. Mismatched Case. To generate an HTML report, click the Generate HTML Report button in the panel.

  9. Mismatched Case. When you’re done, click the Close button in the panel.

    Mismatched Case.

Check for CSS Usage Problems

  1. Check for CSS Usage Problems Click the Tools menu, and then click Accessibility Reports.

  2. Check for CSS Usage Problems Click the Usage tab.

  3. Check for CSS Usage Problems Click the option to specify which pages you want to search.

  4. Check for CSS Usage Problems Select or clear the Check for check boxes you want to include or exclude.

    • Class Selectors. Shows the CSS classes in use.

    • ID Selectors. Shows the CSS ID selectors in use.

    • Element Selectors. Shows all HTML element selectors. This option generates a lot of output; use only if necessary.

  5. Element Selectors. Click Check.

    Element Selectors.
  6. Element Selectors. To view report information, double-click the entry, and then view the highlighted code.

  7. Element Selectors. To sort or filter information in the panel, click a column header, or click the column list arrow, and then click a filter or Custom to use AutoFilter.

  8. Element Selectors. To view a list of style sheet links, click the Style Sheet Links button in the panel.

  9. Element Selectors. When you’re done, click the Close button in the panel.

    Element Selectors.

Setting CSS Options

The CSS tab in the Page Editor Options dialog box allows you to control how Expression Web uses CSS styles in your Web pages. You can use the CSS tab to override default CSS behavior in Expression Web. By default, Expression Web automatically adds CSS code to your Web pages when you apply formatting based on the options set in the CSS tab. You can set different CSS properties for different page elements, such as font and text, borders, background, sizing, positing, and floating.

Set CSS Options

  1. Set CSS Options Click the Tools menu, and then click Page Editor Options.

  2. Set CSS Options Click the CSS tab.

  3. Set CSS Options Select the CSS options you want. Some of the common options include:

    • Auto Style Application. This option automatically applies CSS styles to formatting text based on the selected CSS technology properties.

    • Manual Style Application. This option displays the Style Application toolbar so you can apply styles manually.

    • Only reuse classes with the prefix “style.”Select to change automatically added CSS classes to start with the prefix “style,” which prevents Expression Web from modifying them.

    • Use width and height attributes for images instead of CSS. Select to override CSS width and height settings.

  4. Use width and height attributes for images instead of CSS. Click OK.

    Use width and height attributes for images instead of CSS.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.72.224