Internet & World Wide Web How to Program, 5/e 1. 2.

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

1 Cascading Style Sheets™ (CSS) Outline 5.1 Introduction 5.2 Inline Styles 5.3 Embedded Style Sheets 5.4 Conflicting Styles 5.5 Linking External Style.
Cascading Style Sheets (CSS) “Styles” for short. Pg. 418.
Today CSS HTML A project.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
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} //
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
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.
Cascading Style Sheets. Slide 2 Lecture Overview Overview of Cascading Style Sheets (CSS) Ways to declare a CSS CSS formatting capabilities New features.
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Lecture 7 Cascading Style Sheets (CSS) Boriana Koleva Room: C54
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
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 (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 09: Cascade Style Sheets - Spring 2011.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Cascading Style Sheet (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.
Tutorial 6 By Sam INE 1020 Introduction to Internet Engineering 1 DHTML & CSS Tutorial 6.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Tutorial 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 3.
IS 360 Declaring CSS Styles. Slide 2 Introduction Learn about the three ways to declare a style Inline / embedded / external Learn about the effect of.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
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.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
Introduction to CSS September 20, Introduction Cascading Style Sheets (CSS) –Separation of structure from presentation CSS guide and tutorial.
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:
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
IN THE DOCUMENT OBJECT MODEL, EACH LINE OF HTML IS AN ELEMENT (AN OBJECT), ABLE TO HAVE ATTRIBUTES, PROPERTIES AND VALUES. CSS TELLS THE BROWSER HOW TO.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
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 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…
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
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.
Instructor: Sergey Goldman
Cascading Style Sheets™ (CSS)
Chapter 6 - Cascading Style Sheets™ (CSS)
Cascading Style Sheets™ (CSS)
CSS: Cascading Style Sheets
Chapter 6 Cascading Style Sheets™ (CSS)
IS 360 Declaring CSS Styles
Using Cascading Style Sheets Module B: CSS Structure
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheets
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Intro to CSS CS 1150 Spring 2017.
Second CSS Lecture Applications to XML
Cascading Style Sheets™ (CSS)
Cascading Style Sheets
CSS Applications to XML 20-May-19.
Cascading Style Sheets™ (CSS)
Presentation transcript:

Internet & World Wide Web How to Program, 5/e 1

2

3

 Cascading Style Sheets 3 (CSS3)  Used to specify the presentation of elements separately from the structure of the document.  CSS validator jigsaw.w3.org/css-validator/  This tool can help you make sure that your code is correct and will work on CSS3-compliant browsers. 4

 Inline style  declare an individual element’s format using the HTML5 attribute style.  Figure 4.1 applies inline styles to p elements to alter their font size and color.  Each CSS property is followed by a colon and the value of the attribute  Multiple property declarations are separated by a semicolon 5

最好的方法是用 external link 6

7

8

 color property sets text color  Color names and hexadecimal codes may be used as the color property value.  Figure 4.2 contains the HTML standard color set.  A list of extended hexadecimal color codes and color names is provided in Appendix B.  You can also find a complete list of HTML standard and extended colors at  / 9

10

 A second technique for using style sheets is embedded style sheets, which enable you to embed a CSS3 document in an HTML5 document’s head section.  Figure 4.3 creates an embedded style sheet containing four styles. 11

12

13

14

The style Element and MIME Types  Styles that are placed in a style element use selectors to apply style elements throughout the entire document  style element type attribute specifies the MIME type (the specific encoding format) of the style sheet. Style sheets use text/css.  Figure 4.4 lists common MIME types used in this book. For a complete list, visit:  (What is MIME type?) 15

16

 A CSS rule has two main parts: a selector, and one or more declarations. Source: 17

 The style sheet’s body declares the CSS rules for the style sheet.  To achieve the separation between the CSS3 code and the HTML5 that it styles, we’ll use a CSS selector to specify the elements that will be styled according to a rule.  An em element indicates that its contents should be emphasized.  Each rule body in a style sheet is enclosed in curly braces ( { and } ). 18

 font-weight property specifies the “boldness” of text. Possible values are:  bold  normal (the default)  bolder (bolder than bold text)  lighter (lighter than normal text)  Boldness also can be specified with multiples of 100, from 100 to 900 (e.g., 100, 200, …, 900). Text specified as normal is equivalent to 400, and bold text is equivalent to

Style Classes  Style-class declarations are preceded by a period (.). (class selector)  They define styles that can be applied to any element.  In this example, class special sets color to purple.  You can also declare id selectors.  If an element in your page has an id, you can declare a selector of the form #elementId to specify that element’s style. 20

font-family Property  font-family property specifies the name of the font to use.  Generic font families allow authors to specify a type of font instead of a specific font, in case a browser does not support a specific font. 21

22

font-size Property  font-size property specifies the size used to render the font.  You can specify a point size or a relative value such as xx-small, x-small, small, smaller, medium, large, larger, x-large and xx-large.  Relative font-size values are preferred over points, because an author does not know the specific measurements of each client’s display.  Relative values permit more flexible viewing of web pages.  For example, users can change font sizes the browser displays for readability. 23

Applying a Style Class  In many cases, the styles applied to an element (the parent or ancestor element) also apply to the element’s nested elements (child or descendant elements).  Multiple values of one property can be set or inherited on the same element, so the browser must reduce them to one value for that property per element before they’re rendered.  We discuss the rules for resolving these conflicts in the next section. 24

 Figure 4.3 contains an example of inheritance in which a child em element inherits the font-size property from its parent p element.  However, in Fig. 4.3, the child em element has a color property that conflicts with (i.e., has a different value than) the color property of its parent p element.  Properties defined for child and descendant elements have a higher specificity than properties defined for parent and ancestor elements.  Conflicts are resolved in favor of properties with a higher specificity, so the child’s styles take precedence.  Figure 4.6 illustrates examples of inheritance and specificity. 25

Defines the class nodec that can only be used by anchor elements Sets the properties for the hover pseudoclass for the a element, which is activated when the user moves the cursor over an anchor element All em elements that are children of li elements set to bold Applies underline style to all h1 and em elements 26

27

28

29

 Pseudoclasses give you access to content that’s not declared in the document.  hover pseudoclass is activated when the user moves the mouse cursor over an element. 30

31

 Relative length measurements:  px (pixels – size varies depending on screen resolution)  em (usually the height of a font’s uppercase M)  ex (usually the height of a font’s lowercase x)  Percentages (of the font’s default size)  Absolute-length measurements (units that do not vary in size):  in (inches)  cm (centimeters)  mm (millimeters)  pt (points; 1 pt = 1/72 in)  pc (picas; 1 pc = 12 pt) 32

33

 External style sheets are separate documents that contain only CSS rules.  Help create a uniform look for a website  Separate pages can all use the same styles.  Modifying a single style-sheet file makes changes to styles across an entire website (or to a portion of one).  When changes to the styles are required, you need to modify only a single CSS file to make style changes across all the pages that use those styles. This concept is sometimes known as skinning. 可設計一個可以適用於整個 website 的 CSS 34

 Figure 4.7 presents an external style sheet.  CSS comments may be placed in any type of CSS code (i.e., inline styles, embedded style sheets and external style sheets) and always start with /* and end with */. 35

36

 Figure 4.8 contains an HTML5 document that references the external style sheet.  link element  Uses rel attribute to specify a relationship between two documents  rel attribute declares the linked document to be a stylesheet for the document  type attribute specifies the MIME type of the related document  href attribute provides the URL for the document containing the style sheet 37

38

39

40

41

 CSS position property  Allows absolute positioning, which provides greater control over where on a page elements reside  Normally, elements are positioned on the page in the order in which they appear in the HTML5 document  Specifying an element’s position as absolute removes it from the normal flow of elements on the page and positions it according to distance from the top, left, right or bottom margin of its parent element 42

43

44

45

 The z-index property allows a developer to layer overlapping elements  Elements that have higher z-index values are displayed in front of elements with lower z-index values 46

 Figure 4.10 demonstrates relative positioning, in which elements are positioned relative to other elements. 47

48

49

50

  The tag defines a division or a section in an HTML document.  The tag is a block-level element. ( 會換行 )  The tag is often used to group block-elements to format them with styles.   The tag provides no visual change by itself.  The tag is an inline-level element. ( 不會換行 )  The tag provides a way to add a hook to a part of a text or a part of a document.  這兩個 tag 對於 CSS 和 JavaScript 很重要 51

 Tutorial:   HTML Formatter:   CSS Formatter: 

 所有顏色代碼:   挖出特定網站的配色:   色票:  