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.

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

กระบวนวิชา 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 Lecture #5 Static Web Documents Shimrit Tzur-David HAIT Summer 2005.
© Yaron Kanza HTML,CSS and JavaScript Written by Dr. Yaron Kanza, Edited by permission from author by Liron Blecher.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
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 Cascading Style Sheets (CSS) DBI Overview of CSS.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
CSS: Cascading Style Sheets. What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Cascading Style Sheets (CSS). DBI 2008 HUJI-CS 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages.
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.
4.01 Cascading Style Sheets
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
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.
CSS: Cascading Style Sheets. 2 History HTML tags were originally designed to define the content of a document. The layout of the document was supposed.
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).
TECH2018 Multimedia and the Internet More about CSS and Page Layouts.
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 CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.
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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
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
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
 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.
CSS My favourite ICT lesson By Federico Boschi Cascading Style Sheets.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 7.
Css. Definition Cascading style sheet (CSS) Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
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.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
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.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
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.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Lesson 15: Cascading Style Sheets. Objectives Identify ways to apply Web page formatting with Cascading Style Sheets (CSS1 and CSS2) using various methods.
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.
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.
Managing Data on the World-Wide Web cs What is HTML? A Markup Language for representing documents text (data) structure appearance functionality.
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.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS: Cascading Style Sheets Part II. Style Syntax.
1 CSS: Cascading Style Sheets W3Schools CSS tutorialCSS tutorial.
CSS Cascading Style Sheets *referenced from
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.
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.
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,
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.
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Presentation transcript:

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 is specified by style rules The style rules appear either in the document or in external files, called style sheets

3 Style Sheets Usually, a file that ends with.css Contains a list of style rules for HTML elements Case insensitive Comments are enclosed in /* */ For example: -i.a.cnn.net/cnn/.element/ssi/css/1.1/main.css (CNN) - (HUJI) Demo:

4 Without a style sheet

5 Simple Example A Joke A joke A mama tomato, a papa tomato and a baby tomato are walking down the street. The baby tomato keeps falling behind so the papa tomato goes back, steps on the baby tomato and says, ketchup ("Catch-up!").

6

7 Style File: joke.css body { background-image: url("bg.gif"); } h1 { background-color: green; color: rgb(250, 200, 250); /* pink */ font-family: cursive } p { background-color: yellow; color: purple; font-size: 200%;}

8 Simple Example (with css) A Joke A joke A mama tomato, a papa tomato and a baby tomato are walking down the street. The baby tomato keeps falling behind so the papa tomato goes back, steps on the baby tomato and says, ketchup ("Catch-up!").

9

10 Why do we Need a Style Sheet? Separates content from format Reduces download time (how?) In HTML 4.01 styling is very limited Consistent appearance over a site Allows to easily change style -In one page -In a whole site

Inserting Style to a Page

12 How and Where? The style rules appear either in the document or in external files, called style sheets -Inside a document, there are inline styles and embedded style sheets -External style sheets are either linked or imported

13 Inline Styles In an inline style, the declaration block appear as the value of the attribute style of the element Almost every tag can have the style attribute -exceptional: base, head, html, meta, param, script, style and title This text will be shown in italic green and the size will be 1.5 times the current font size

14 Document-Level Style (Embedded) body {color: red; background: skyblue;} h1 { color: blue }...

15 Link External Style Sheets...

16 rule imports style rules to the beginning of the style sheet rule imports the style rules of another style sheet Several import rules may appear Imported Style url(general.css); body { color: red; background:skyblue } h1 { color: blue } An Example:

17 Cascading of Styles CSS merges style rules from different places (inline, document-level, imported and linked) Different places may have conflicting style rules The process of merging (“cascading”) styles from different places determines which style rules have priority Will be discussed later…

Style Syntax

19 Style Rules h1 { color: purple; font-family: Impact, Arial Black; font-size-adjust:.46; font-size: 2.33em; font-weight:400; font-style:normal; text-decoration: none; word-spacing:normal letter-spacing:normal; text-transform: none; } Declaration Property Value(s) Selector

20 Style Rules (cont) A rule has the following form selector {declaration block} The selector determines when the rule is applied For example, the following rule applies to text that is inside a tag p {color: green; font-size: 1.5em; font-style: italic}

21 What Kind of Properties can a CSS Style Sheet Change? Style properties Layout properties There are many properties and many possible values -We will not cover all of them here -Everything is in the Web ! -A good source:

Style Properties

23 Our Examples We use the following HTML example: This is our example for css. The tag is used to group elements for formatting with styles -Extremely useful tag...

24 Font Properties Font properties: family, size, weight, style, variant,... span { font-family: courier; font-size: 130%; font-style: italic; font-weight: bold}

25 Text Properties Text properties: color, transform, decoration, … span { color: #00cc00; text-decoration: line-through; text-transform: uppercase}

26 Background Properties Background properties: background-color, background-image, … span {background-color: #00ff00} span {background-image: url('bg.gif');}

Layout Properties

28 Page Layout Each HTML element defines a layer (rectangular box) that is placed in some location on the page Layers are nested with correspondence to the nesting of their elements

29 Inline vs. Block Elements There are two types of elements: Block elements: p, ol, table, div, h1, etc. Inline elements: b, i, a, span, cite, etc. Layers of block elements are separated from their adjacent elements (i.e., a new line before and after), while inline elements are not You can turn a block into an inline and vice-versa, using the display property, e.g., h1 { display: inline }

30 Positioning Elements Using CSS, you can define the position of an element inside its parent layer For that, use the properties position, left, right, top and bottom span { position:relative; left: 1cm; top: 1cm; color: #00cc00;}

31 Relative vs. Absolute In CSS, positions (of boxes) and sizes (of fonts and boxes) could be either relative or absolute In an “absolute” style -Font size is fixed -Sizes and positions of elements are fixed In a “relative” style -you can change the font size -The sizes and positions of elements may change when the size of the window is changed

32 Position Types But 1cm left to what?? For that, we have the position property Four position types: - static : the default position - absolute : relative to the parent layer coordinates - relative : relative to the static position - fixed : relative to the window coordinates

33 Position Examples span { position:absolute; left: 1cm; top: 1cm; color: #00cc00;} span { position:fixed; left: 1cm; top: 1cm; color: #00cc00;}

34 Position Examples span { position:static; left: 1cm; top: 1cm; color: #00cc00;} Totally Ignored! This is the default position type

35 More Layout Properties Layer properties - margin-top (-bottom, -left, -right) - padding-top (-bottom, -left, -right) - border-width (-color, -style, … ) Text Layout - direction, word-spacing, white-space, letter- spacing, line-height, text-align, text-indent, …