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.

Slides:



Advertisements
Similar presentations
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} //
Advertisements

Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
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.
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.
Web Design & Development Cascading Style Sheets (CSS)
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
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.
Cascading Style Sheets. What is a style sheet? >A controlling document (or part of the document) >Sets the default appearance of items on the web page.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Lecture CSS: Cascading Style Sheets. What are Styles? Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics.
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
© 2007 D. J. Foreman CSS-1 Cascading Style Sheets Styles.
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.
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
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.
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:
Introduction to CSS CSS Syntax - Fort Collins, CO Copyright © XTR Systems, LLC Cascading Style Sheets - Syntax & Semantics Instructor: Joseph DiVerdi,
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. 2 What are Style Sheets A style sheet is a mechanism that allows to specify how HTML (/XHTML/XML) pages should look The style.
CSS – Cascading Style Sheets Fred Durao
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.
CSS My favourite ICT lesson By Federico Boschi Cascading Style Sheets.
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.
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.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
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…
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets Objective: Create an external style sheet, embedded style sheet, and an inline style to change the look and feel of a web site.
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.
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.
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.
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.
Developing Web Applications with HTML and CSS “Selectors and Properties”
CSS: Cascading Style Sheets Part II. Style Syntax.
1 CSS: Cascading Style Sheets W3Schools CSS tutorialCSS tutorial.
CSS Cascading Style Sheets *referenced from
Class & ID Selectors, Font and List Properties. Id Selectors  # followed by Id-name (without space)  Can be used once on a page  Examples: #p1 { color:
Basic Webpage Design Cascading Style Sheet (CSS).
Tutorial 3 Designing a Web Page with CSS
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
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.
CSS Details Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  To use CSS properties for fonts  Evaluate whether to use pts,
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.
Internet & World Wide Web How to Program, 5/e 1. 2.
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets
Presentation transcript:

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 Netscape introduced it in 4.0 release

Cascading Style Sheets3 Style Sheet Essentials n Style sheets can be used in 3 primary ways: –Inline style sheets n Apply a style sheet to an individual element by using the -tag –Embedded style sheets n Apply a style sheet to the entire document by using the -tag –External (linked) style sheets n Link an external style sheet to the document by using the -tag

Cascading Style Sheets4 Style Sheet Essentials n Example of Using Inline Style n Example of Embedded Style Sheet n Example of Linked Style Sheet

Cascading Style Sheets5 Rules and Style Sheets n Rule –Statement about one stylistic aspect of one or more elements n Style sheet –One or more rules that apply to an HTML document

Cascading Style Sheets6 Rule n A rule consists of 2 parts –Selector n Link between HTML document and the style –Declaration n What the effect is H1 {color : red} selectordeclaration

Cascading Style Sheets7 Grouping n The three rules H1 {font-weight : bold} H2 {font-weight : bold} H3 {font-weight : bold} can be written as H1, H2, H3 {font-weight : bold}

Cascading Style Sheets8 Grouping n The two rules H1 {color : red} H1 {text-align : center} can be written as H1 {color : red; text-align : center}

Cascading Style Sheets9 Inheritance n tag tag n A tag inherits the properties of an enclosing tag Section Two: Big Nails Section Two: Big Nails –If style sheet specified all tags were red and didn’t mention, the Big would also be red

Cascading Style Sheets10 Inheritance n One property can have a value that is relative to its parent property P {font-size: 14 pt} P {line-height: 120%} –Line height is defined as a percentage of font size

Cascading Style Sheets11 Contextual Selectors n Apply styles contextually –Can set to green, to red, and all instances of that occur inside to blue H3 EM {color: blue} n This is different from H3, EM {color: blue} which states that both h3 and em are blue

Cascading Style Sheets12 Contextual Selectors n Consider H3 EM, H2 I {color: yellow} –This is the same as H3 EM {color: yellow} H2 I {color: yellow}

Cascading Style Sheets13 Text-Specific Style Attributes n font-family –{font-family:times} n font-size –in pt, in, cm, px, % –{font-size:24px} n font-style –{font-style:italic}

Cascading Style Sheets14 Text-Specific Style Attributes n font-weight –extra-light, extrabold, medium, light, demi-light, demi-bold, bold n text-decoration –none, underline,italic,line-through n line-height –in, cm, px %, pt

Cascading Style Sheets15 Text-Specific Style Attributes n margin-left n margin-right n margin-top n margin-indent n text-align n The unit for all of the above attributes can be in inches, pixels, points, or centimeter

Cascading Style Sheets16 Inline Styles n Adding a style attribute to individual tags in a document Hello there! Hello there!

Cascading Style Sheets17 Document Level Style Sheets n Place list of rules within the head of an HTML document –Rules are enclosed within … -tags n -tag has type attribute –type=text/css –type=text/javascript n JavaScript style sheets (to be discussed later)

Cascading Style Sheets18 Document Level Style Sheets <html> Hello There! Hello There! <!-- /* Make all H1 headers red and italic */ H1: {color: red; font-style: italic} --></style>

Cascading Style Sheets19 Document Level Style Sheets <body> Hello There!! Hello There!! What’s new? What’s new? </body></html>

Cascading Style Sheets20 External Style Sheets n Linked –Currently, this is only way which works <html> Hello There! Hello There! <link rel=stylesheet type=“text/css” href=“ edu/hello/gen_styles.css” title=“Hello”> </head>

Cascading Style Sheets21 External Style Sheets n Linked <body> Hello There!! Hello There!! What’s new? What’s new? </body></html>

Cascading Style Sheets22 External Style Sheets n Imported <html> Hello There! Hello There! url( url( edu/hello/spec_styles.css);

Cascading Style Sheets23 External Style Sheets n Imported BODY: {background: url(bg/lake.gif)} --></style></head><body> Hello There!! Hello There!! What’s new? What’s new? </body></html>

Cascading Style Sheets24 Linked Versus Imported n One -tag –Loads style and formats appropriately n Document level and inline-styles override n Two or more -tags –Standard is that browser presents user with choice n Netscape loads all of them, with later rules overriding earlier ones n IE loads only first one –User selects one –Browser ignores others

Cascading Style Sheets25 Linked Versus Imported n More than statement leads to a merging of styles –Suppose gen_styles.css says to make yellow and bold and spec_styles.css says to make red n Then is red and bold –If we later define a document-level style which makes purple, then is purple and bold

Cascading Style Sheets26 Linked Versus Imported n Imported styles override linked external styles <html><head> <style>

Cascading Style Sheets27 Linked Versus Imported n Imported styles override linked external styles url(sheet4.css) --></style></head>

Cascading Style Sheets28 Linked Versus Imported n Imported styles override linked external styles –Browser will prompt user to choose between sheet1.css and sheet2.css –Will then load selected sheet, followed by sheet3.css and sheet4.css –Duplicate styles defined in sheet3.css or sheet4.css and in any inline styles will override styles in user-chosen sheet

Cascading Style Sheets29 Style Precedence n Sort by origin –A 'closer' style takes precedence over a 'farther' style n Inline takes precedence over document-level n Document-level takes precedence over external n Sort by class –Properties defined as class of tag take precedence over properties defined for tag in general

Cascading Style Sheets30 Style Precedence n Sort by specificity –Properties defined for a more specific contextual style take precedence over properties defined for a less specific context n Sort by order –A later property takes precedence over an earlier one n IE takes only first rule definition and ignores subsequent ones

Cascading Style Sheets31 Syntax n Basics tag-selector {property1:value1; property2:value1 value2 value3; …}

Cascading Style Sheets32 Syntax n Multiple selectors H1, H2, H3 {text-align: center} H1, H2, H3 {text-align: center} is same as H1 {text-align: center} H2 {text-align: center} H3 {text-align: center}

Cascading Style Sheets33 Syntax n Contextual selectors –Examples OL LI {list-style: upper-alpha} OL OL LI {list-style: upper-roman} OL OL OL LI {list-style: lower-alpha} OL OL OL OL LI {list-style: decimal}

Cascading Style Sheets34 Syntax n Contextual selectors –Examples H1 EM, P STRONG, H2 {color: red} –More specific rule is given precedence P STRONG {color: yellow} P UL STRONG {color: blue}

Cascading Style Sheets35 Classes n Regular classes –Associated with tags <!-- P.abstracts {font-style: italic; left-margin: 0.5cm; right-margin: 0.5cm} P.equations {font-family: Symbol; text-align: center}

Cascading Style Sheets36 Classes n Regular classes H1, P.centered {text-align: center; left-margin: 0.5cm; right-margin: 0.5cm} --><style>

Cascading Style Sheets37 Classes n Regular classes This is an abstract This is an abstract An equation: An equation: c=y-9</p> Hello there! Hello there!

Cascading Style Sheets38 Classes n Example

Cascading Style Sheets39 Classes n Generic classes –Not associated with any tag.italic {font-style: italic} –Examples Hello there Hello there

Cascading Style Sheets40 Classes n Pseudo-classes –Three associated with -tag n A:link {color: red} n A:active {color: red; font-weight: bold} n A:visited {color: yellow} –Two associated with -tag n P:first-line {font-style: small-caps} n P:first-letter {font-size:200%; float: left}

Cascading Style Sheets41 Property Values n Keywords –small –xx-large –bolder –underline –line-through

Cascading Style Sheets42 Property Values n Length –Relative n em –Height of current font n ex –Height of letter 'x' in current font –Pixels n px

Cascading Style Sheets43 Property Values n Length –Absolute n inches –in n centimeters –cm n millimeters –mm n points –1/72 inch –pt n picas –12 points –pc

Cascading Style Sheets44 Property Values n Length –Percentage line-height: 120% –URL url(service://server.com/pathname) n Relative to style sheet's URL –Color rgb(255, 255, 255) rgb(50%,5 0%, 0%)

Cascading Style Sheets45 Property Values n Font properties –Font-family <p style="font-family: Times, 'New Century Schoolbook', Palatino, sans- serif} –Font-size P {font-size: 12pt} P {font-size: 120%} P {font-size: +2pt} P {font-size: larger}

Cascading Style Sheets46 Property Values n Font-properties –Font-size n smaller n xx-small n x-small n medium n large n x-large n xx-large

Cascading Style Sheets47 Property Values n Font-properties –Font-style H3 {font-style: italic} –Font-weight H3 {font-weight: bolder} n lighter n extra-light n light n demi-light

Cascading Style Sheets48 Property Values n Font-properties –Font-weight n medium n demi-bold n bold n extra-bold

Cascading Style Sheets49 Property Values n Color and background properties n Text properties n Box properties –Elements fit within a rectangular box –Can control the size, appearance, and position of these boxes n List properties