3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.

Slides:



Advertisements
Similar presentations
Chapter 3 © 2003 by Addison-Wesley, Inc Introduction - HTML is primarily concerned with content, rather than style - However, tags have presentation.
Advertisements

Part 3 Introduction to CSS. CSS Text Text Styles h1 {color: green} // rgb(0,255,0), #00ff00 h2{letter-spacing: 0.5cm} // 2px h3 {text-align: right} //
1 Dynamic HTML: Cascading Style Sheets™ (CSS). 2 Introduction Cascading Style Sheets (CSS) –Specify the style of your page elements –Spacing, margins,
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
Web Design & Development Cascading Style Sheets (CSS)
1 CSS Styling with Fonts and Colors. 2 CSS Cascading Style Sheets and fonts CSS provides Style or Presentation options for our html pages CSS properties.
Cascading Style Sheets (CSS) Why do we need them? Separate structure from browser presentation There are many HTML presentation attributes –We want to.
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.
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.
Cascading style sheets - CSS
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Formatting Text (Plus More Selectors) Learning Web Design: Chapter 12.
Selectors thru Borders. CSS – Cascading Style Sheets – is a way to style HTML HTML is the content base of a web page CSS provides the presentation qualities.
CSS1-1 Cascading Style Sheets (CSS) Xingquan (Hill) Zhu
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).
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.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 14 – Dynamic HTML: Cascading Style Sheets (CSS) Outline 14.1Introduction 14.2Inline Styles.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
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:
Tutorial 6 By Sam INE 1020 Introduction to Internet Engineering 1 DHTML & CSS Tutorial 6.
Cascading Style Sheets " Provide means to control and change presentation of HTML documents. " Allow the user to impose a standard style. " Three levels.
CSS – Cascading Style Sheets Fred Durao
3-Oct-15 CSS First CSS Lecture Applications to HTML.
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.
Class three: CSS review, backgrounds, font formatting, the box model.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
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.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
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.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
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,
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
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.
CSS for Styling CS The good, the bad and the… ugly!  Tags such as b, i, u, and font are discouraged in strict XHTML  Why is this bad? CS380 2.
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
Web Design (14) CSS Formatting Text. Formatting Text In Brackets, go to your ‘externalcss’ website and find the ‘formattingtext’ page. Use the ‘main’
Chapter 3 Cascading Style Sheets. © 2006 Pearson Addison-Wesley. All rights reserved Introduction - The CSS1 specification was developed in 1996.
CSS Cascading Style Sheets *referenced from
Basic Webpage Design Cascading Style Sheet (CSS).
Font-Family, Color and Background. Basics  CSS rule: Selector (multiple separated by, ) Declaration (multiple separated by ; ) Example: p { color: red;
03 CSS (Cascading StyleSheet) Р.Жавхлан МОНГОЛ УЛСЫН ИХ СУРГУУЛЬ Мэдээллийн технологийн сургууль Интернэт технологийн үндэс 2015 Намар.
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,
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.
Internet & World Wide Web How to Program, 5/e 1. 2.
HTML WITH CSS.
Cascading Style Sheets™ (CSS)
Creating Your Own Webpage
Stylin’ with CSS.
Cascading Style Sheets™ (CSS)
Stylin’ with CSS.
Cascading Style Sheets
Stylin’ with CSS.
Cascading Style Sheets™ (CSS)
Presentation transcript:

3.1 Cascading Style Sheets

Motto Fashions fade, style is eternal. —Yves Saint Laurent

Purpose Cascading Style Sheets (CSS) –specify the presentation of elements e.g., font, position, … –separate from the document's structure Three types –Inline Styles –Embedded Style Sheets –External Style Sheets CSS validator jigsaw.w3.org/css-validator/

Inline Styles Inline style –declared using the style attribute within in the element’s start tag good only for this element The value of the style attribute: –semicolon-separated list of properties –form: property-name : property-value –e.g., –Inline Styles don't separate content and layout

Inline Styles: Example Inline Styles The text in this paragraph has the font-size 20pt. and is rendered in magenta color.

Embedded Style Sheets Define styles for an entire document Can associate a set of style properties –with a particular XHTML element e.g., with, with, with, with … will be applied to each such element –independent of any elements identified by (class) name can be applied to an arbitrary element

Embedded CSS: Form element –within –attribute type="text/css" the MIME type (encoding format) –inner text must follow syntax: list of rules a rule consist of a name and set of properties name is either an element name or a class name (see next) set of properties is enclosed in { and } a property is specified as in Inline Styles

Style Classes Class name –arbitrary letters and - no spaces In style definition –preceded by. –can be combined with an element form: element-name.class-name e.g., a.nodec {text-decoration: none} –applies only to

Embedded CSS: Sample em { font-weight: bold; color: purple } h1 { font-family: helvetica, sans-serif } p { font-size: 12pt; font-family: arial, sans-serif }.blue { color: #6666ff } Meaning: –every text within will be bold and black –every text within will be in Helvetica or sans-serif font –every text within will be in Arial or sans-serif font –every element with class="blue" will be in color #6666ff (light blue)

Embedded CSS: Example … Embedded CSS Let me emphasize this and color this. And do it also in this section. And in another section again.

Embedded CSS: Example 2 em { font-weight: bold; color: red } h1 { font-family: courier, monospaced } p { font-size: 10pt; font-family: garamond, serif }.blue { color: blue }

Precedence of Styles If there are several styles for one element, which one will be applied? precedence: 1.user 2.author (you) 3."user agent" (=browser) within document: –the more specific wins –the innermost wins

Font Properties font-family –comma–separated list (in order left-to-right) of font names, e.g., times-roman, helvetica, courier generic fonts: serif, sans-serif, monospace, cursive font-style – normal, italic, oblique font-weight –relative: normal, bold, bolder, lighter –absolute: 100, 200, 300, …, 900 font-size –relative: n %, xx-small, x-small, small, smaller, medium, larger, large, x-large, xx-large –absolute: n pt, n em, n ex, … (see next slide)

Unit Values Absolute – pt : points – px : pixels – in : inches – cm : centimeters – mm : milimeters – pc : picas Relative (to default font size) – % : percent – em : height of the letter M – ex : height of the letter x

Font Properties: Guidelines font-family –always end the list with a generic font serif, sans-serif, monospace, … font-weight, font-size –use relative rather than absolute values –accessibility!

Text Properties text-align – left, right, center, justify text-indent –length or percent (see previous slide) –indentation of the 1 st line text-decoration – underline, overline, blink, line-through color –see next slide

Color Values Predefined colors: – black, white, gray, red, green, blue, yellow, aqua, fuchsia, lime, maroon, navy, olive, purple, silver, teal Colors in hex –start with # –then 6 hex digits, 2 for each red, green, blue –e.g. #ff00ff : ff red, 00 green and ff blue = magenta

Lecture-specific questions What colors is # ? And what color is #ff0000 ? Can you write white in another way? Write an style rule that makes a link purple if the user's mouse is on top of the link.

Background Properties background-color –see previous slide background-image –URL –laid over background-color background-repeat – repeat, repeat-x, repeat-y, no-repeat –whether and in which dimension to repeat the image

Pseudoclasses Provide access to content not specifically declared in the document Form: –element-name : pseudoclass –no surrounding spaces! hover pseudoclass is used when the mouse is on top of an element –e.g., a:hover {color: purple}

External Style Sheets A separate document with only CSS rules Complete separation of contents and style Used to create websites with uniform look –several (all) pages can use the same styles –change in a single style-sheet file changes styles across the entire website

Link to an External Style Sheet element –within the element – rel="stylesheet" attribute relation to linked document – type="text/css" attribute MIME type – href attribute URL of the external style sheet

External Style Sheets: Form simply a list of CSS rules –see Embedded Style Sheets e.g., – em { font-weight: bold; color: purple } h1 { font-family: helvetica, sans-serif } p { font-size: 12pt; font-family: arial, sans-serif }.blue { color: #6666ff }

External Style Sheets: Example E.g., several pages, one style

Another External Style Sheet Same pages, only the single external CSS changed

Guidelines Always use external style sheet for a website! –consistent look-and-feel –faster development –faster browsing downloaded once, stored, applied to all pages Test your CSS in all common browsers –Firefox, I-Explorer, Opera, Safari, Google Chrome Run your CSS through W3C CSS Validator