LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 7: CSS Building Blocks.

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

Cascading Style Sheets
XP Introducing Cascading Style Sheets With Cascading Style Sheets (CSS), you can create one or more documents that control the appearance of some or all.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Week 7 Web Typography. 2 Understanding Type Design Principles.
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 4 Creating Special Effects with CSS
4.01 Cascading Style Sheets
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Online Chapter 1 4 th Edition.  Review elements  Whitespace handling  Rule structure  Linking to an external style sheet  Alternate Style Sheets.
Cascading style sheets (CSS)
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Principles of Web Design 6 th Edition Chapter 5 – Web Typography.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
Cascading Style Sheet (CSS)
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
XP New Perspectives on XML Tutorial 5 1 TUTORIAL 5 CSS Tutorial – Carey ISBN
Today’s objectives  Presentational | Inline | Block | Validate  CSS | Rules | Declarations.
Chapter 12 Cascading Style Sheets: Part II The Web Warrior Guide to Web Design Technologies.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
Website Development & Management Working with Style Rules Instructor: John Seydel, Ph.D. CIT Fall
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Tutorial #4 Formatting Text and Links. Tutorial #3 Review - CSS CSS format Selector { property1: value1; /* Comments */ } Embedded, In-Line, and External.
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.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
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.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
Slide 1 CMPS 211 Internet Programming Spring 2008 Style Sheet Building Blocks Chapter 7 & 8 4/8/08.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 8: Working with Style Sheets.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
CS 174: Web Programming September 9 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Developing Web Applications with HTML and CSS “Selectors and Properties”
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
INTRODUCING CSS What CSS does How CSS works Rules, properties, and values.
CSS Cascading Style Sheets *referenced from
Tutorial 3 Designing a Web Page with CSS
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition.
Chapter 11 & 12 CSS Style Sheets: Intro. Why CSS? Separate presentation from content – more accessible Less work – can change appearance of whole site.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
What is CSS? A set of style rules that tell the web browser how to present a web page or document. – In earlier versions of HTML, style characteristics,
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 10: Formatting Text with Styles.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Formatting Text with CSS
4.01 Cascading Style Sheets
Cascading Style Sheets
Madam Hazwani binti Rahmat
Web Systems & Technologies
SEEM4570 Tutorial 3: CSS + CSS3.0
Tutorial 3 Working with Cascading Style Sheets
Cascading Style Sheets
4.01 Cascading Style Sheets
Presentation transcript:

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 7: CSS Building Blocks

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Objectives Construct style rules for webpages with CSS. Add CSS comments. Understand how inheritance works. Apply the cascade to conflicting style rules. Determine specificity, order, and importance. Apply values to CSS properties. Specify colors for CSS properties using RGB and hexadecimals. Explore new color options in CS3 using RGBA, HSL, and HSLA.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE CSS Building Blocks CSS (Cascading Style Sheets): Defines content’s appearance. Style sheet: A text file containing rules for displaying elements in a webpage. CSS controls basic formatting, layout, print controls, and dynamic properties. CSS2 is the best-supported version. –CSS3 builds upon CSS2 with new features. CSS can be created outside of the webpage and then applied to many pages all at once.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Constructing a Style Rule Each style rule has two main parts: selector and declaration block. Selector indicates which elements will be formatted. Declaration block describes the formatting to be executed. –Made up of one or more property/value pairs. –Each property/value pair constitutes a declaration. –Order of declarations doesn’t matter unless the same property is defined twice. –Left curly brace begins a declaration block, and right curly brace ends it.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE To Construct a Style Rule Type selector to identify element(s) to format. Type { (an opening curly bracket) to begin declaration block. Type property: value;, –Property names CSS property that describes formatting. –Value is one of a list of allowable options for that property. Repeat property: value; step as needed. –Enter each property: value (a declaration) on its own line. Type } to complete declaration block and style rule.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Adding Comments to Style Rules Comments do not display in webpages. Add comments to CSS to: –Note primary sections of style sheets. –Explain a particular rule or declaration. CSS comments help you and anyone else looking at your code. To add comments to style rules: –In your style sheet, type /* to begin your comment. –Type the comment. –Type */ to signal the end of the comment

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Understanding Inheritance Inheritance determines what happens if no other style rule is applied to an element. Many CSS properties are inherited by the descendants of the elements to which they’ve been applied. You can also use a value of inherit with most properties to force inheritance. Inheritance is the weakest rule, overruled by any other rule.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Which Properties Are Inherited? Text: color (except by the a element), direction, font, font-family, font-size, font-style, font-variant, font- weight, letter-spacing, line-height, text-align, text- indent, text-transform, visibility, white-space, word- spacing Lists: list-style, list-style-image, list-style-position, list-style-type

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Which Properties Are Inherited? Tables: border-collapse, border-spacing, caption- side, empty-cells Paged media (as in printing): Orphans, page- break-inside, widows Other: Cursor, quotes

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE The Cascade: When Rules Collide Override or complement default browser style in three ways: –Load styles from an external file (Recommended). –Insert at the top of an HTML document. –Apply to specific HTML element in the code. Cascade: When more than one style rule applies to an element, CSS uses this principle to determine which of the conflicting rules wins. Principle of cascade takes into account three characteristics: specificity, order, and importance.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Specificity Law of specificity states that the more specific the selector, the stronger the rule—and the conflicting style in the stronger rule wins.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Order and Importance Order: When two rules have equal specificity, then rules that appear later in the style sheet take precedence. Rules applied inline in the HTML element are considered to appear after—and thus take precedence over—equally specific rules in an external style sheet or embedded at top of HTML document. Importance: Override whole system by declaring a particular rule more important than the others by adding !important at the end of the declaration.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE A Property’s Value Each CSS property has different rules about what values it can accept. –Inherit value: Use to explicitly specify that the value for the property be the same as the parent element’s value. –Predefined values: Most CSS properties have a few predefined values. –Lengths and percentages: Many CSS properties take a length for their value. All length values must state quantity and unit, with no spaces between.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Code for Preset Value

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Lengths and Percentages Length types can be relative or absolute units. Only use absolute lengths when size of output is known. Ems, pixels, and percentages are most common. –Ems are relative to some other value. –Pixels (px) are not relative to other style rules. Pixels aren’t necessarily the same size on two devices. –Percentage values are generally relative to their parent element’s value.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Code for Length and Percentage

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Bare Numbers Very few CSS properties accept a value in the form of a number without a unit. –Most common are line-height and z-index. Don’t confuse numbers and integers with length. –A number or integer has no unit (like px).

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE URLs Some CSS properties allow URL of another file to be specified, particularly images. –Use url(file.ext) Relative URLs should be relative to style sheet, not HTML document. Quotation marks around the file name aren’t required. No space between the word url and the opening parentheses. White space between parentheses and address allowed, but not required.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE Code for Specifying a URL

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE CSS Colors Specify colors for CSS properties in several ways. –Value can be one of the predefined color keywords. Easiest method. –In practice, more common to define CSS colors with the hexadecimal format or RGB format. –Can also specify a color with the HSL format, and the level of color transparency with RGBA and HSLA. All of which are new in CSS3.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE CSS Colors

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE RGB and Hexadecimal RGB Construct your own color by specifying its amount of red, green, and blue. Give the values for each of these contributing colors as a number from 0–255, a percentage, or a hexadecimal representation of the number. Hexidecimal Convert those numerical values to hexadecimals, join them together, and prefix the value with a # –Most common method.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE More Color Options in CSS3 CSS3 adds RGBA, HSL, and HSLA. RGBA is RGB with alpha transparency. –Set transparency with decimal between 0 and 1. HSL stands for hue, saturation, and lightness. –Hue is a number from 0–360. Both saturation and lightness are percentages between 0 and 100. –Think of hue as a degree on a circle, with 0 and 360 meeting at the top. 0 and 360 are the same color—red. HSLA is HSL with alpha transparency.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE RGBA RGBA is RGB with alpha transparency.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HSL and HSLA HSL stands for hue, saturation, and lightness. –Hue is a number from 0–360. Both saturation and lightness are percentages between 0 and 100. –Think of hue as a degree on a circle, with 0 and 360 meeting at the top. 0 and 360 are the same color—red. HSLA is HSL with alpha transparency.

LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE RGBA, HSL, and HSLA in IE Pre-IE9 doesn’t supports RGBA, HSL, or HSLA. –Ignore any declaration they don’t understand. For RGBA and HSLA, workaround exists for pre-IE9. For HSL, specify colors with hexadecimal (or RGB). Last option uses IE’s Gradient filter with proprietary code that no other browser understands. –Means modern browsers will ignore and use standard CSS.