Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.

Similar presentations


Presentation on theme: "Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving."— Presentation transcript:

1 Cascading Style Sheets

2 Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving a consistent look Allow mass changes to entire site by changing the style

3 Cascading Style Sheets Multiple sheets can influence a single page Sheets can cascade effects to other sheets, each adding new features Complete specification can be downloaded at: WWW.W3.ORG

4 Types of Styles Inline Styles –Styles are added directly to the HTML tag Global Styles –Style is applied to the entire HTML document External Style Sheet –Styles are kept in a separate document with the.CSS extension –Multiple pages can share the style sheet

5 Inline Styles A style can be specified directly on an HTML tag without referring to a separate style sheet this approach allows use of the expanded parameters of a style not usually associated with an HTML tag

6 Global Style Definition To hide from older browsers that don’t support, enclose in a comment tag: <! - - style sheet rules here - - >

7 Style Rules Style is a collection of rules Rules have the syntax: selector { styles } Selector is the tag to be modified –example Styles are the properties that are being specified –example COLOR

8 Example Change all paragraphs to be blue and be italicized P { color: blue; font-style: italic } This is a demo of a style. All paragraphs will now have blue, italics It affects the entire document

9 Selectors Type Selectors –Identify the entire class of HTML tags to be modified Id Selectors –Identify a name that can be used to specify selectively which HTML tags are modified

10 Selectors Context Selectors –Identifies HTML tags to be modified within the context of other HTML tags Class Selectors –Creates a class that various HTML tags can belong to based on the CLASS parameter

11 Type Selector Example: Change Ordered and Unordered List Items to use italics and bold UL, OL { font-style: italic; font-weight: bold}

12 ID Selector #MyParaA { font-style: italic; font- weight: bold} #MyParaB { color: red}

13 Context Selector UL LI { color: red} OL LI { color: blue } Line items in an unordered list will be red Line items in an ordered list will be blue

14 Class Selector.MyClass { font-style: italic; font-weight: bold}.MyRedClass { color: red}...

15 Combination Selector LI.MyRedClass { color: red} this will only affect the LI tags that use this class this won’t be part of the class Other type tags using the class won’t be affected

16 and Create an area on the HTML page that can cover multiple tags A is separated from adjacent areas by a line break A can be in the middle of text Both can be modified by styles

17 span { color: red} this is before the span this is inside the span other tags can be inside a span this is still inside the span this is after the span

18 div { color: red} this is before the div this is inside the div other tags can be inside a div this is still in the div this is after the span and will be separated by a line break

19 Parent Styles are Inherited by Children Children’s styles will override their parents

20 Styles In Separate Documents Allows multiple HTML pages to share Place inside tags URL should refer to a file with an extension of.CSS

21 Styles In Separate Documents CSS document contains only the definitions of the style rules ( i.e. no tags) P { color:red }

22 Linking with @import Alternative method to reference external style sheet Microsoft Extension CSS can include styles from another CSS @import url(stylesheet.css) additional styles

23 Style Precedence Inline Style Overrides Global Style Global Style Overrides External Style Sheet Style Sheets that Reference Other Style Sheets Override the Referenced Sheets Anything Not Specified Defaults to the Browser Settings

24 Absolute Positioning Styles can be used to positioning an element on a page in an exact position, instead of the normal “flow” of HTML POSITION: absolute TOP: top of element LEFT: left edge of element Z-INDEX: Layer effect -- higher indexes appear in front lower indexes

25 Absolute Positioning style="POSITION: absolute; LEFT: 127px; TOP: 253px; Z-INDEX: 100” This style would place the element’s upper left corner 252pixels from the top, and 127 pixels from the left edge of the window. It would appear on top of any other element in the same location with an index < 100


Download ppt "Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving."

Similar presentations


Ads by Google