Review: Three parts to a webpage: - Content - Structure  XHTML - Presentation  CSS In this chapter we will focus on introducing and examining the mechanics.

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
1 Getting Started with CSS. 2 CSS Cascading Style Sheets XHTML provides structure for our documents (web pages) CSS provides Style or Presentation for.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
SM5312 week 6: basic CSS syntax1 An Introduction to Cascading Style Sheets Basic CSS Syntax Nick Foxall.
Controlling Page Style: Cascading Style Sheets (CSS) References: 1.Wang, P.S & Katila, S. (2004). A Introduction to Web Design and Programming. CA: Thomson.
More HTML Chapter 4. 2 Nesting Tags How do you write the following in HTML? The wrong way: This is really, REALLY fun ! Tags must be correctly nested.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks).
CompSci Today’s topics Networks & the Internet Basic HTML ä The basis for web pages ä “Almost” programming Upcoming ä Connections ä Algorithms.
XHTML and CSS Introduction to XHTML and CSS Bharti Patel 1 phones off (please)
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
1 Web Developer Foundations: Using XHTML Chapter 9 Cascading Style Sheet Concepts.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheet (CSS)
Today’s objectives  Complete web page  Using xhtml & CSS  Adding CSS to documents Embed url(File);  CSS.
Today’s objectives  Presentational | Inline | Block | Validate  CSS | Rules | Declarations.
SE-2840 Dr. Mark L. Hornick 1 Separating Structure from Presentation: CSS.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Part 1: CSS - Why? - How it works - Writing rules - Examples.
Cascading Style Sheets CSS by Pavlovic Nenad by. 2Cascading Style Sheets Presentation Contents What are CSS? What are CSS? History of CSS History of CSS.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Tutorial 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
WRT235: Writing in Electronic Environments Basic CSS.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
HTML - Quiz #2 Attendance CODE:
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
Creating Your Own Webpage COSC Cascading Stylesheets Think of: HTML: content of your webpage HTML has tags CSS: presentation and appearance of your.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
The Web Wizard’s Guide To DHTML and CSS Chapter 1 A Review of CSS1.
>> More on CSS Selectors. Pre-requisite Open the file called sample.txt Copy the all the text from the file Open your browser and go to codepen.io Paste.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
CSS – 1h. Without stylesheets proprietary HTML extensions making text into images proliferate use of "spacer" GIF images deprecated HTML elements and/or.
Cascading Style Sheets Primary readings Presentations Explain & review projects with class mates.
Developing Web Applications with HTML and CSS “Selectors and Properties”
How CSS Works CHAPTER 2 1 CHARLES WYKE-SMITH: STYLIN’ WITH CSS: A DESIGNER’S GUIDE (3 ND EDITION)
CSS: Cascading Style Sheets Part II. Style Syntax.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
CH 12 CSS Style Sheets 1. Objective What is CSS? Selecting elements Different rules for different media Importing style sheets 2.
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
>> Introduction to CSS
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets
Presentation transcript:

Review: Three parts to a webpage: - Content - Structure  XHTML - Presentation  CSS In this chapter we will focus on introducing and examining the mechanics of CSS and how we can use style sheets to “beautify” the structure of a webpage.

Cascading Style Sheet A list of rules that define a particular style that is applied to XHTML markup. Ex: Font size of a paragraph, thickness of a border around an image, position of a headline. Gives web designers complete control over the layout of their web pages. Three ways to add CSS to a web page: Inline Embedded Linked

Put style declarations right in a specific tag with the “style” attribute. Not recommended and very rarely used. CSS and XHTML were implemented to get rid of presentational markup. Will override any styles declared in a linked or embedded style sheet. By adding inline CSS styling to this paragraph, we can override the default styles.

Place CSS styles in the head of your XHTML document. Again, not recommended because the scope is limited to one page. Will override a linked style sheet, but will still lose to an inline style. Embedded Styles h1 {font-size: 16px;} p {color:blue;} Link to example

Ideal method of using CSS  Truly separates presentation from structure. Styles have a site-wide scope  Can change one thing in the style sheet and it will impact every page that links to it. Can specify styles that make the page look good on different media (print, mobile, etc.) Embedded Styles Can change to other media types (list)list

Let’s make a sample page linked to an external style sheet. External Styles All paragraphs will be modified. See? Same style. It also has the same effect on us header 2’s. See? external.html style.css p {color:red;} h2 {color:blue; font-style:italic;} Link to example

Each rule in CSS follows a specific format: Selector {Property:value;} The selector is the corresponding tag in the XHTML markup. The property is one of the valid CSS style attributes (a good list of them). The values correspond to the specific property and can also be found on the w3schools CSS reference list.a good list of them

Multiple declarations can be contained within a rule. p {color:red; font-size:12px; line-height:15px;} Multiple selectors can be grouped. h1, h2, h3, h4 {color:red; font-size:12px;} Multiple rules can be applied to the same selector h1, h2, h3, h4 {color:red; font-size:12px;} h1 {font-style: italic;}

A CSS style declaration will apply to every tag of the selector’s type. In order to make it apply to only a certain part of your document, you must utilize XHTML’s document hierarchy. Here's the biggest heading. Here's a smaller one. This h1 won't have the style applied to it. hierachy.html div h1 {color:red;} style2.css Link to example

The second way of defining specific styles without the use of the document hierarchy is by adding “class” and “id” attributes to the XHTML markup. Define classes with a. This will be some special text This, unfortunately, won’t be. But this will be! This won’t. class1.html h1 {color:red;} p {color:blue;}.special {font-family: Helvetica, sans-serif; font-style:italic;} style3.css Link to example

If you want to, say, target one paragraph with a given class, you can write the following: p.special {font-family: Helvetica, sans-serif; font-style:italic;} You can also combine the document hierarchy with classes to further specify styles: Here's the biggest heading. Here's a smaller one. This h2 won't have any class styles applied to it. h1 {font-color:red;}.small {font-size:x-small;}.big {font-size:x-large;}.big span {font-style:italic;} style4.css class2.html Link to example

IDs work almost exactly like classes in that they can be used to identify specific portions of a webpage that will be styled. However, an ID is more powerful than a class because it is used to identify unique pieces of a page (header, footer, etc.). Can also be used to enable JavaScript to be triggered, and takes precedence over classes in cascading. This is special text p#specialtext {css rules;}

Tell the browser to only apply a certain style if a certain condition is met. Universal Selector *  All markup will contain the specified style, unless overridden. * {color:green;} Adjacent Sibling Selector +  Selects a tag that follows a specific sibling tag h1 + p {font-variant:small-caps;} Test This will be in small caps This won’t be Attribute Selectors []  Targets only elements with specific attributes img[title] {border: 2px solid blue;}

Cause rules to be applied when certain events occur. Most often used for mouse clicks or hovers. Anchor Link Pseudo-Classes Most commonly used with hyperlinks and color changing Link, Visited, Hover, Active Ex: a:link {color:black;} a:visited {color:gray;} a:hover {text-decoration:none;} a:active {color:navy;} Will set the link color to black, the link’s color to gray if you’ve clicked on it, removes the underlining when hovered, and changes the color to navy when the user holds the mouse down on the link.  You can use “hover” on any element to change its style when the mouse is hovered over it. Link to example

Adds markup around already existing content. first-letter, first-line, before, after “before” and “after” are useful for displaying items retrieved from a database in a coherent manner. Ex: number retrieved from db h2:before {content:”The user is “;} h2:after {content:” years old.”;} If the number was 25, the output on the page would be “The user is 25 years old.”

Inheritance is passing a style down the document hierarchy. Declaring the font family, color, etc. in the body selector will make the text in every text element that font type. Many properties are not inherited because it doesn’t make sense for them to be– e.g. a border will not be inherited by a table cell (td) inside a table with a border. Inheritance is cumulative– that is, if you define a tag’s font size as 80% and it is descendant from a tag with font size 80%, that child tag’s font size will be 64% (80% of 80%).

Cascading describes the process of letting the browser decide which styles to apply to a tag, amidst many possible style declarations. Browsers follow a natural hierarchy of styles, with each one below taking precedent over the ones above: Default browser style sheet User style sheet (rare, but useful for the visually impaired) Author style sheet (external / linked CSS file existing on the server) Author embedded styles Author inline styles Selectors with IDs have precedence over classes, which have precedence over selectors only. The more specific the style declaration, the higher the precedence. Defined styles override any inherited style, regardless of specificity.

Example of higher specificity: p {color:red;} p.largeText {color:orange;} p#largeText {color:yellow;}div p#largeText {color:green;} div ul.myList {background-color:blue;} Each has higher specificity than the one preceding it, thus giving each precedence over the ones before it. Link to example

Three types of values: Words Numerical Values Color Values Words  font-weight: bold; Numerical Values  font-size:12px; Color Values  color:#336699; For font sizes, when possible, and to retain consistency with page resizing and user styles, set the “base” font-size to 1em in the body, and use other size declarations as proportions of that base size. E.g. font-size:.5em will yield half the size of the base.

For color values, you have three options for declaring colors: Words  aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow Hexadecimal  #RRGGBB = 0, FF = 255 Percentages  R%, G%, B% color:black; color:#000000; color:rgb(0%, 0%, 0%);