Web Chapter.02

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Tutorial 2Using Styles to Format Web Pages : 

Tutorial 2Using Styles to Format Web Pages

Objectives : 

New Perspectives on Blended HTML, XHTML, and CSS 22 Objectives Identify the differences between HTML and CSS Write CSS styles Choose the correct style to format a Web page Create an embedded style Specify fonts with font properties Control line spacing and white space Change text and background color on a Web page Create and apply inline styles

Introducing Cascading Style Sheets : 

Introducing Cascading Style Sheets With Cascading Style Sheets (CSS), you can create one or more documents that control the appearance of some or all the pages at your Web site Greater consistency in your Web site Easily modified code More flexible formatting Across-the-board compatibility with all browsers is called cross-browser support No browser supports all features of CSS New Perspectives on Blended HTML, XHTML, and CSS 33

Comparing HTML Code to CSS Code : 

Comparing HTML Code to CSS Code New Perspectives on Blended HTML, XHTML, and CSS 44

Creating a CSS Rule : 

Creating a CSS Rule In a text document, type the selector followed by a left brace, as in the following code, and then press the Enter key. selector { Type the declarations, separating a property from a value with a colon, and then type a semicolon, as in the following code. property:value; Type a right brace to end the declaration list. The following code shows the syntax for a complete rule selector { property1:value; property2:value; } New Perspectives on Blended HTML, XHTML, and CSS 55

Guidelines for Writing CSS Rules : 

Guidelines for Writing CSS Rules When writing CSS rules, make sure you include the following parts of the code: Left brace before the declaration list Colon between each property and its value Semicolon at the end of each declaration Right brace at the end of the declaration list Spacing, indentation, line returns, or the position of the braces are irrelevant New Perspectives on Blended HTML, XHTML, and CSS 66

Using the Three Types of CSS Styles : 

Using the Three Types of CSS Styles An external style is one in which you write the CSS code in a document separate from the HTML for the Web page An embedded style is one in which you write the CSS code in the <head> section of an HTML document An inline style is one that is written in the <body> section of an HTML document New Perspectives on Blended HTML, XHTML, and CSS 77

Creating an Embedded Style : 

Creating an Embedded Style Embedded styles apply styles locally to a single Web page New Perspectives on Blended HTML, XHTML, and CSS 88

Changing the Font : 

Changing the Font In CSS, styles are grouped according to their function. One of the most commonly used groups is the font properties New Perspectives on Blended HTML, XHTML, and CSS 99

Changing the Font : 

Changing the Font New Perspectives on Blended HTML, XHTML, and CSS 1010

Changing the Font : 

Changing the Font You use the font-size property to change the size of type New Perspectives on Blended HTML, XHTML, and CSS 1111

Changing the Font : 

Changing the Font You use the font-variant property to display lowercase text in small caps, which is smaller than regular capitals The font-family property changes the typeface New Perspectives on Blended HTML, XHTML, and CSS 1212

Changing the Font : 

Changing the Font New Perspectives on Blended HTML, XHTML, and CSS 1313

Setting Other Properties to Style Text : 

Setting Other Properties to Style Text The CSS line-height property changes vertical spacing between lines of text, a feature not available in HTML margin property New Perspectives on Blended HTML, XHTML, and CSS 1414

Setting Other Properties to Style Text : 

Setting Other Properties to Style Text New Perspectives on Blended HTML, XHTML, and CSS 1515

Using the font Shortcut Property : 

Using the font Shortcut Property The font property is a shortcut property, which means you can use it to specify more than one declaration at a time font-style font-weight font-variant font-size line-height margin font-family New Perspectives on Blended HTML, XHTML, and CSS 1616

Using Color on a Web Page : 

Using Color on a Web Page In HTML code, you can refer to colors in several ways—by name, RGB value, hexadecimal value, or “short hex” value RGB values are based on the intensity of red, green, and blue The hexadecimal values for colors represent the intensity of red, green, and blue New Perspectives on Blended HTML, XHTML, and CSS 1717

Using Color on a Web Page : 

Using Color on a Web Page New Perspectives on Blended HTML, XHTML, and CSS 1818

Using the color Property : 

Using the color Property The CSS color property changes the foreground color, which determines the color of text New Perspectives on Blended HTML, XHTML, and CSS 1919

Setting the background-color Property : 

Setting the background-color Property You use the background-color property to change the background color of an element New Perspectives on Blended HTML, XHTML, and CSS 2020

Grouping Selectors : 

Grouping Selectors If you want more than one HTML selector to have similar declarations, you do not have to create a separate rule for each selector New Perspectives on Blended HTML, XHTML, and CSS 2121

Using Contextual (Descendent) Selectors : 

Using Contextual (Descendent) Selectors In HTML, you can nest tags to apply multiple formatting features to the same text You can nest CSS code by specifying a selector within another selector, which is called a contextual selector New Perspectives on Blended HTML, XHTML, and CSS 2222

Using the display Property : 

Using the display Property The display property is one of the CSS classification properties New Perspectives on Blended HTML, XHTML, and CSS 2323

Creating and Applying an Inline Style : 

Creating and Applying an Inline Style To create and apply an inline style, you place the style code within the tag in the HTML document where you wish the style to take effect New Perspectives on Blended HTML, XHTML, and CSS 2424

Creating and Applying an Inline Style : 

Creating and Applying an Inline Style New Perspectives on Blended HTML, XHTML, and CSS 2525