Cascading Style Sheets By Mimi Opkins. What We’ll Cover uSpecifying style sheet rules uExternal and inline style specifications uCreating new HTML elements.

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

Computer Applications II.  A Style Sheet is a web page development tool that allows the developer to make global changes to a web page (or web site)
กระบวนวิชา 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.
Chapter 6 Web Typography
CASCADING STYLE SHEETS CSS. 2 What CSS means?  CSS is an extension to basic HTML that allows you to style your web pages.  It separates the part that.
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.
Beginning Web Site Creation: Dreamweaver CS4. XHTMLCSS  Describes the structure  Content  Collection of styles  Formatting body { background-color:
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Cascading Style Sheets1. 2 n Style sheets are a means of controlling the way HTML tags are formatted n IE introduced style sheets in IE 3.0 release n.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
Formatting Text (Plus More Selectors) Learning Web Design: Chapter 12.
TECH2018 Multimedia and the Internet More about CSS and Page Layouts.
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.
Cascading Style Sheets Example
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.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
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.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
WORKING WITH CASCADING
Chapter 6 Web Typography. 2 Principles of Web Design Chapter 5 Objectives Understand principles for type design on a Web site Use the element Understand.
CSS: Cascading Style Sheets. 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
 A style sheet is a single page of formatting instructions that can control the appearance of many HTML pages at once.  If style sheets accomplished.
Using Cascading Style Sheet As you create more web pages, you may wish to impose a consistent look for all of your web pages or for group of related pages.
CSS My favourite ICT lesson By Federico Boschi Cascading Style Sheets.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
CASCADING STYLE SHEETS. Chapter 3 Objectives Customize HTML elements Specify Font characteristics Classes Tag style Inline and block-level elements External.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Cascading Style Sheets Chapter Four. What are they? A set of style rules that tell the web browser how to present a web page or document. Cascading Style.
CO1552 – Web Application Development Cascading Style Sheets.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
1 Web Development CSS (Cascading Style Sheet). 2 1.Setting rules for multiple elements To decrease the amount of typing for setting rules for multiple.
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,
©SoftMoore ConsultingSlide 1 Introduction to HTML: Cascading Style Sheets.
Cascading Style Sheets Web Design Fairport High School.
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
Developing Web Applications with HTML and CSS “Selectors and Properties”
CSS: Cascading Style Sheets Part II. Style Syntax.
Cascading Style Sheets (CSS)
CSS Cascading Style Sheets *referenced from
Basic Webpage Design Cascading Style Sheet (CSS).
03 CSS (Cascading StyleSheet) Р.Жавхлан МОНГОЛ УЛСЫН ИХ СУРГУУЛЬ Мэдээллийн технологийн сургууль Интернэт технологийн үндэс 2015 Намар.
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.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
CSS Details Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  To use CSS properties for fonts  Evaluate whether to use pts,
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
1 Cascading Style Sheets
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Internet & World Wide Web How to Program, 5/e 1. 2.
IS 360 Declaring CSS Styles
Using Cascading Style Sheets Module B: CSS Structure
3 Configuring Color & Text With CSS.
Introduction to CSS.
The Internet 10/13/11 The Box Model
CSS Style Sheets: Intro
Presentation transcript:

Cascading Style Sheets By Mimi Opkins

What We’ll Cover uSpecifying style sheet rules uExternal and inline style specifications uCreating new HTML elements through style sheet classes uSpecifying font and text properties uControlling spacing and alignment uControlling foreground and background properties

Benefits of Cascading Style Sheets uPowerful and flexible way to specify the formatting of HTML elements u Can define font, size, background color, background image, margins, etc. uShare style sheets across multiple documents or entire Web site uCan specify a class definition for a style, effectively defining new HTML elements uRules are applied in a hierarchical manner

Specifying Style Rules uGeneral form of rule selector {property:value} or selector {property1:value1; property2:value2; … propertyN:valueN} uExample H1 {text-align:center; color:blue }

Example - No Style Sheet No CSS Example 1 No CSS Example 1 Advantages of Style Sheets Cascading Style Sheets (CSS) make the web a better place by allowing you to more easily and quickly control the layout of your web pages. CSS will make your life much richer and the world a better place to live.

Result - No Style Sheet

Example, With Style Sheet CSS Example 1 BODY { background-image: URL(“earth.gif”) } H1 { text-align:center; font-family: Arial } H2 { font-family: "Comic Sans MS" } STRONG {text-decoration: underline }

Result, With Style Sheet

Ways to Use Style Sheets uLinking to an External Style Sheet uEmbedding a Style Sheet uInline Style Sheets

External Style Sheets uSpecify link to external style sheet in the HEAD section of the HTML uMystyle.css H1 {text-align: center; font-family: Arial} H2 {color: #440000; text-align: center; font-family: “Arial Black”, Arial, sans-serif}

Embedded Style Sheet uCode the sheet with a in the section of the HTML CSS Example 1 BODY { background-image URL(agc.gif) } H1 { text-align:center; font-family: Arial } H2 { font-family: "Comic Sans MS" } STRONG {text-decoration: underline } ….

Inline Style Sheets uUse the STYLE attribute for each HTML element to directory specify the style Style Sheets are great <P STYLE=“margin-left: 0.5in; margin-right: 0.5in; font-style: italic”> This slide show will teach you some of the basics of using Cascading Style Sheets.

Defining Element Style Classes uTo define an element style class, proceed the HTML element by a period and class name P.abstract {margin-left: 0.5in; margin-right: 0.5in; font-style: italic}

Using Element Style Classes uTo use, supply the name of the style class in the CLASS attribute of the HTML element Style Sheets are great This slide show will teach you some of the basics of using Cascading Style Sheets.

Defining Global Style Classes uTo define a global style class, omit the element name.blue {color:blue; font-weight: bold }

Using Global Style Classes uTo use, specify the style class in the CLASS attribute of the HTML element A Blue Heading This text is in the default color, but this text is blue.

Defining Contextual Selectors uDefines styles in a given context (ex. a tag within a tag) uExample: P B {color:red} uThis stylesheet rule tells the browser to make all bold text red only if it appears within text

Result Contextual Selectors uExample: Mimi Opkins, Teacher Java, HTML, CSS, Ethics. All these subjects, what does she really like the best? uResult: Mimi Opkins, Teacher Java, HTML, CSS, Ethics. All these subjects, what does she really like the best?

Inheritance uStylesheet rules are inherited from “parent” to “child” uExample: B {color:blue} All my Web pages will use cascading stylesheets within four weeks. uResult: There’s no rule for the, but since it occurs within the, it inherits the style for

Conflicting Style Sheets uWhat happens if an embedded style sheet, inline style sheet and a linked style sheet all define rules for the same element? uExample: A linked style sheet says is blue, an embedded says is green and an inline says is yellow

Style Sheet Precedence Rules 1. Inline Styles 2. Embedded Styles 3. Linked Styles 4. Default Browser Styles

Font Properties ufont-weight ufont-style ufont-size ufont-family utext-decoration

font-weight uRelative weight (boldness) of font unormal | lighter |bold | bolder | xxx u where xxx is 100, 200, …, 900 u Normal nonbold text is 400 uExample: H1 { font-weight: 200} H2 { font-weight: bolder}

font-style uFont face type within a family unormal | italic | oblique uExample: P{ font-style:normal } TH{ font-style:italic }

font-size uEither relative or absolute size of font uThree basics ways to specify the size u points, ems, pixels and other units u keywords u percentage values

Points, Ems uPoints - absolute size as in print media P {font-size: 16pt} uRefers to the size of the parent element P {font-size: 20pt} B {font-size: 1.5em} Any text within text would be 30 points (1.5 times that of its parent)

Pixels uScreen measurement uConsistent across all platforms uHowever, web pages will not print consistently uExample: P {font-size: 20px}

Other Units uin-inches ucm-centimeters umm-millimeters upc-picas uExample: P {font-size: 1in} u xx-small u x-small u small u medium u large u x-large u xx-large u Example: P {font-size:large}

Example, font properties-HTML Camp CECS <LINK REL=STYLESHEET HREF="CampCECS.CSS" TYPE="text/css"> Camp CECS We have the following activities: Computer Building Compiler Construction Software Engineering Java Brewing

Example, font properties-CSS H1 {text-align: center; font-family: "Comic Sans MS"} H2.computer {font-size: 30pt} H2.compiler {font-style: italic} H2.software {font-size:.75em; font-weight: 800;} H2.java {font-family: "Algerian"}

Result, font properties

text-decoration uDescribes text additions or decorations that are added to the text of an element unone|underline|overline|line-through| blink uExample: P {text-decoration: underline}

Alignment and Spacing utext-align uvertical-align utext-indent umargin-top, margin-bottom, margin-left, margin-right

text-align uDetermines how paragraph are positioned horizontally uleft|right|center|justify uExample: P {text-align:right}

vertical-align uDetermines how elements are positioned vertically utop|bottom|text-top|text-bottom| baseline|middle|sub|super uExample: P {vertical-align: super}

text-indent uSpecifies the indentation of the first line of the paragraph u+/- pt,pc,in,cm,mm|+/- em,ex,px,% uExample: P {text-indent: -25px}

Margins uEnable you to control the margin around each side of an element umargin-top, margin-bottom, margin-left, margin-right uExample: H4 {margin-top: 20px, margin-bottom: 5px; margin-left:100px; margin-right:55px}

Example, Alignment & Spacing - HTML Letter to the Lakers January 15,2003 Jedi Master, Yoda Universal Force Owner Los Angeles Lakers Los Angeles, CA To Whom It May Concern: I wish to thank you for your generous offer to join your basketball team. However, I must decline. Since I'm sure you don't need me for my height, I must come to the conclusion that you want me for my levitation skills. This would not be a proper use of the force. Sincerely, Master Yoda

Example, Alignment & Spacing - CSS BODY {margin-right: 0.5in; margin-left: 0.5in} P {margin-top: 25px} P.rhead {text-align:right; margin-right: 1.5in; font-family: sans-serif} P.lhead {font-family: sans-serif} P.body {text-align: justify; text-indent: 0.5in } P.foot {margin-left: 60%} B {vertical-align: sub}

Result, Alignment & Spacing

Foreground and Background Properties ucolor ubackground-color ubackground-image

color uColor of the text or foreground color ucolor-name|#RRGGBB u color-name (blue, yellow, green, red, etc.) u #RRGGBB - Red, Green, Blue hexidecimal values uExample: B {color: blue}

background-image uSpecifies an image to use as the background of any element unone|url(filename) u url can be either relative (images/bg.gif) or a full url ( uExample: TABLE {background-image: url(abc.gif)}

background-color uAdds a solid color behind any element on a page, including images ucolor-name|#RRGGBB u color-name (blue, yellow, green, red, etc.) u #RRGGBB - Red, Green, Blue hexidecimal values uExample: P.yellow {background-color: #FFFF66}

Example, Foreground & Background - HTML Color Properties <LINK REL=STYLESHEET HREF=color.css TYPE="text/css"> This is a very strange example of use of color.

Example, Foreground & Background - CSS BODY {background-image: url(earth.gif)} P.yellow {background-color: yellow; color:red}

Result, Foreground & Background

Credits uThanks to the following for input to this presentation: u Core Web Programming, Cascading Style Sheets by Marty Hall, Larry Brown u Mulder’s Stylesheets Tutorial by Steve Mulder