CH 12 CSS Style Sheets 1. Objective What is CSS? Selecting elements Different rules for different media Importing style sheets 2.

Slides:



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

Intro To Cascading Style Sheets By Mario Yannakakis.
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. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
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.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
กระบวนวิชา 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.
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
Chapter 8 Creating Style Sheets.
Tutorial 3 Introducing Cascading Style Sheets. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Learn about Cascading Style Sheets Write.
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:
SM5312 week 6: basic CSS syntax1 An Introduction to Cascading Style Sheets Basic CSS Syntax Nick Foxall.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
W EB S ITE L ECTURE C ASCADING S TYLE S HEETS. Cascading Style Sheets (CSS) Introduction CSS Objectives – Provide more control over web site content presentation.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
© 2012 Adobe Systems Incorporated. All Rights Reserved. LEARNING THE LANGUAGE OF THE WEB INTRODUCTION TO HTML AND CSS.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Review: Three parts to a webpage: - Content - Structure  XHTML - Presentation  CSS In this chapter we will focus on introducing and examining the mechanics.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
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.
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  Complete web page  Using xhtml & CSS  Adding CSS to documents Embed url(File);  CSS.
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.
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.
 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.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 14, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
Tutorial 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
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.
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.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
3. Cascading Style Sheets (CSS) M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 4 CASCADING STYLE SHEET G H E F.
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.
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.
Cascading Style Sheets CSS2 - a bit more advanced.
CSS: Cascading Style Sheets Part II. Style Syntax.
Creating Layouts with CSS. Span tag Here is some underlined text. Here is some blinking text. Here's some bold text.
Tutorial 3 Designing a Web Page with CSS
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
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.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
Cascading Style Sheets Robin Burke ECT 270. Outline CSS properties Fonts Alignment Color CSS selection selectors.
Web Design & Development
Presentation transcript:

CH 12 CSS Style Sheets 1

Objective What is CSS? Selecting elements Different rules for different media Importing style sheets 2

What is CSS? What Are Cascading Style Sheets? CSS CSS - stand for Cascading Style Sheets CSS CSS is a declarative language introduced in 1996 as a standard means of adding information about style properties to HTML Properties such as fonts and borders 3

What is CSS?  A simple CSS style sheet A CSS style sheet contains a list of rules. Each rule gives the names of the elements It applies to and the styles to apply to those elements.css The three letter extension.css is conventional, but not required 4

What is CSS? 5 This style sheet has five rules. Each rule has a selector POEM { display: block } TITLE { display: block; font-size: 16pt; font-weight: bold } POET { display: block; margin-bottom: 10px } STANZA { display: block; margin-bottom: 10px } VERSE { display: block } POEM { display: block } TITLE { display: block; font-size: 16pt; font-weight: bold } POET { display: block; margin-bottom: 10px } STANZA { display: block; margin-bottom: 10px } VERSE { display: block }

What is CSS? first rule The first rule says that the contents of the POEM element should have a line break before and after it (display: block) second rule The second rule says that the contents of the TITLE element should have a line break before and after it (display: block) in 16-point (font- size: 16pt) bold type (font-weight: bold) 6

What is CSS? third rule The third rule says that the POET element should have a line break before and after it (display: block) and should be set off from what follows it by 10 pixels (margin-bottom: 10px) fourth rule The fourth rule is the same as the third rule except that it applies to STANZA Elements Fifth rule Fifth rule simply states that each VERSE element also has a line break before and after it 7

What is CSS?  Comments CSS style sheets can include comments. CSS comments are similar to C’s /* */ comments, but not to the XML and HTML comments 8

What is CSS? Sample of comments in CSS 9 /* Work around a Mozilla bug */ POEM { display: block } /* Make the title look like an H1 header */ TITLE { display: block; font-size: 16pt; font-weight: bold } POET { display: block; margin-bottom: 10px } /* Put a blank line in-between stanzas, only a line break between verses */ STANZA { display: block; margin-bottom: 10px } VERSE { display: block } /* Work around a Mozilla bug */ POEM { display: block } /* Make the title look like an H1 header */ TITLE { display: block; font-size: 16pt; font-weight: bold } POET { display: block; margin-bottom: 10px } /* Put a blank line in-between stanzas, only a line break between verses */ STANZA { display: block; margin-bottom: 10px } VERSE { display: block }

What is CSS?  Three Ways to Insert CSS External style sheet - An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing just one file Internal style sheet - An internal style sheet should be used when a single document has a unique style Inline style 10

What is CSS?  Attaching style sheets to documents You can apply the same style sheet to many documents It’s common to put your style sheets in some central location on your web server Where all of your documents can refer to them; A convenient location is a styles directory in the web server’s document root 11

What is CSS?  DTDs and style sheets The style rules only apply to the content of the document (XML), not to the DTD 12

Selecting Elements selector The part of a CSS rule that specifies which elements it applies to is called a selector. The most common kind of selector is simply the name of an element CSS Selector Patterns 13

Selecting Elements  The universal selector The * symbol selects all elements in the document. This lets you set default styles for all elements 14 * { font-family: “New York” }

Selecting Elements  Grouping selectors If you want to apply a set of properties to some but not all elements, list the element names in the selector separated by commas 15 POET, STANZA { display: block; margin-bottom: 10px }

Selecting Elements  Hierarchy selectors - Child selectors > A child selector uses the greater than sign > to select an element if and only if it’s an immediate child of a specified parent 16 STANZA > VERSE {font-weight: bold } REFRAIN > VERSE {font-style: italic } STANZA > VERSE {font-weight: bold } REFRAIN > VERSE {font-style: italic }

Selecting Elements Descendant selectors A descendant selector chooses elements that are children, grandchildren, or other descendants of a specified element 17 BOOK VERSE {font-weight: bold } POEM VERSE {font-style: italic; font-weight: normal } BOOK VERSE {font-weight: bold } POEM VERSE {font-style: italic; font-weight: normal }

Selecting Elements Adjacent sibling selectors (+) between two element names signifies that the left-hand element precedes the right-hand element at the same level of the hierarchy This rule finds all REFRAIN elements that share a parent with a STANZA element and that immediately follow a STANZA element 18 STANZA+REFRAIN {color: red}

Selecting Elements  Attribute selectors Attribute selectors identify specific element/attribute combinations Square brackets surround the name of the attribute being specified 19 POEM[TYPE] { font-family: “Zapf Chancery”, cursive }

Selecting Elements - Attributes 20 TYPE inside the red bracket specifies a script font for all elements but not plain You can use a ~= to indicate that the attribute value only needs to contain the specified word somewhere within it POEM[TYPE] { font-family: “Zapf Chancery”, cursive } POEM[TYPE~=“SONNET”] { font-style: italic }

Selecting Elements - Attributes This would not find elements whose TYPE attribute contains the word SONNETS or UNISONNET CSS only looks for complete words. It does not look for substrings 21

Selecting Elements - Attributes You can use a |= to indicate that the attribute value needs to begin with the specified word This would not find elements whose TYPE attribute had the value “HEXAMETER SONNET” It would match a POEM with a TYPE attribute having the value “SONNET HEXAMETER” 22 POEM[TYPE |= “SONNET”] { font-style: italic }

Selecting Elements - ID selectors Use when unique element needs a unique style sample This rule makes the first STANZA element, and only the first STANZA element 23 #st1 STANZA#st1 {font-weight: bold}

Selecting Elements - Addressing the first letter Addressing the first letter – Use when to capitalize first letter of a text. :first-letter 24 CHAPTER:first-letter { font-size: 300%; float: left; vertical-align: text-top; margin-right: 12px } CHAPTER:first-letter { font-size: 300%; float: left; vertical-align: text-top; margin-right: 12px }

Selecting Elements - Addressing the first line :first-line Addressing the first line - :first-line selector to the name of an element to create a rule that only applies to the first line of the element, 25 CHAPTER:first-line { font-variant: small-caps }

Pseudo-classes select elements that have something in common, but do not necessarily have the same type Pseudo-classes differ from pseudo-elements in that they always select an entire element, never just a part of it 26

Example of Pseudo-classes are Position of the mouse, the object that has the focus, or whether an object is a link  :first-child The :first-child pseudo-class selects the first child of the named element, regardless of its type 27 STANZA:first-child {font-weight: bold}

 :hover The :hover pseudo-class refers to elements that the mouse or other pointing device is pointing at, but without the mouse button depressed 28 STANZA:hover { font-weight: bold }

Importing Style Sheets rule embeds a different style sheet into an existing style sheet This allows you to build large style sheets from smaller, easier-to-understand pieces An absolute or relative URL is used to identify the style sheets url(poetry.css);

references w-do-i-style-an-xml-file-with-css.html w-do-i-style-an-xml-file-with-css.html CSS How do I style an XML file with CSS 30