CSCE 102 - Chapter 3 (Cascading Style Sheets) CSCE 102 - General Applications Programming 2016-6-7 Benito Mendoza 1 By Benito Mendoza Department of Computer.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Computer Applications II.  A Style Sheet is a web page development tool that allows the developer to make global changes to a web page (or web site)
Chapter 8 Creating Style Sheets.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
XP Introducing Cascading Style Sheets With Cascading Style Sheets (CSS), you can create one or more documents that control the appearance of some or all.
Week 7 Web Typography. 2 Understanding Type Design Principles.
Web-based Application Development Lecture 4 January 19, 2005 Anita Raja.
Cascading Style Sheets (CSS) Why do we need them? Separate structure from browser presentation There are many HTML presentation attributes –We want to.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
Web-based Application Development Lecture 5 January 24, 2006 Anita Raja.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
+ Text & Font Styles Unit 3 Lesson Different Font Categories Sans Serif – block style fonts Example - Rockwell Easy to read and good to use when.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Formatting Text (Plus More Selectors) Learning Web Design: Chapter 12.
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)
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)
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
WORKING WITH CASCADING
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
Chapter 6 Web Typography. 2 Principles of Web Design Chapter 5 Objectives Understand principles for type design on a Web site Use the element Understand.
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.
INTRODUCTION TO HTML5 Styling Text. Change the Font Size  You can use the font-size property to change the font size for a document’s text.  Instead.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
(CSS) More Details Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
 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.
Using Cascading Style Sheet As you create more web pages, you may wish to impose a consistent look for all of your web pages or for group of related pages.
CSS My favourite ICT lesson By Federico Boschi Cascading Style Sheets.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
CASCADING STYLE SHEETS. Chapter 3 Objectives Customize HTML elements Specify Font characteristics Classes Tag style Inline and block-level elements External.
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.
CO1552 – Web Application Development Cascading Style Sheets.
Tutorial 5 Formatting with CSS. Objectives Session 5.1 – Evaluate why CSS styles are used – Determine where to write styles – Create an element selector.
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.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
Stylin’ with CSS Monday October 8 th and Tuesday October 9 th.
Basics of Web Design Chapter 6 More CSS Basics Key Concepts.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
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,
Introduction to CSS. What is CSS? CSS ("Cascading Style Sheets") determines how the elements in our XHTML documents are displayed and formatted. By using.
CSS properties Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
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
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.
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,
Formatting with Styles. Choosing a Font Family font-family property has a special characteristics: you can specify more than one font h1, h2 {font-family:”Arial.
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…
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 10: Formatting Text with Styles.
Creating Web Documents CSS examples (do more later) Lab/Homework: Read chapters 15 & 16. Work on Project 3, do postings.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
Madam Hazwani binti Rahmat
Using Cascading Style Sheets Module B: CSS Structure
Programming the Web using XHTML and JavaScript
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Tutorial 3 Working with Cascading Style Sheets
Presentation transcript:

CSCE Chapter 3 (Cascading Style Sheets) CSCE General Applications Programming Benito Mendoza 1 By Benito Mendoza Department of Computer Science & Engineering The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 2 Structure and content do NOT equal presentation! Presentation is not meant to be determined by HTML elements Defaults exist = 24-pt, bold, Times Roman Reason: Not all Web pages display in PC browser windows Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 3 Styles provide powerful control over the presentation of web pages. Styles are implemented with three different scopes: local, internal, and external. Local styles are confined to a single element Internal styles affect elements in an entire page External styles can affect multiple pages. The term cascading comes from the effect of the way the different styles are applied when more than one exists. Local styles take precedent over internal styles, and internal styles take precedence over external styles. Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 4 Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Redefines the presentation rule (style) for certain elements “Internal” because contained within the HTML source document itself Styles may be defined using different style sheet languages so … … the language used must be specified Internal Style Sheets

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 5 Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More element in section … Internal Style Sheets The style sheet instructions in this elements are: Written in plain text format Using the cascading style sheet language

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 6 Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Also specify default style sheet language for entire HTML document: elements go in the section Internal Style Sheets

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 7 Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Colors Using the element, placed within the element, to create an internal style sheet (defining the color property of the and elements in this example): h2 {color:red} h3 {color:#D61130} h2 { color:red } Style definition Name of tag Property Value

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 8 Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Changes made to the internal style sheet are reflected throughout the document There are over 16 million colors available using the RGB hexadecimal color numbering Colors h2 { color:#D61130 }

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 9 Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Styles can also be used to align headings with the text-align property – left, right, and center, for example: h2 {color:red; text-align:center} Alignment

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 10 Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Font sizes can be set by using: absolute sizes in points (24pt), percentage (150%), or to preset values of xx-small, x-small, small, medium, large, x-large, and xx-large. When fonts are set using absolute sizes, control is taken away from the user, which may make some pages inaccessible to visually impaired persons. Font Size

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 11 Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More The font-style property allows setting an element to italic, or oblique (slanted text similar to italics) The font-weight property is used to create a “bold” appearance and can be set to values from 100 to 900, where 700 is regular bold text Bold and Italic Revisted

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 12 Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More h1 {text-align:center;font-style:italic; font-size:30pt} h3{color:red; font-size:19pt; font-weight:700} Bold and Italic Revisited

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 13 Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More text-decoration controls underline, overline, line- through, and blink (Ugh!) text-transform allows setting text to uppercase and lowercase font-variant allows setting text to small-caps background controls the color background behind the text All these properties can employ a value of “none” which allows removal of any property assigned by another style Beyond Bold and Italic

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 14 Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Paragraph styles only work with complete elements (both the and tags are used) and not when only the tag is used by itself Properties include text-indent for indentation (a positive value is a normal indent, a negative value, a hanging indent) and line-height Property values can be in points (pt) or a percentage (150%) of the font size Kerning (spacing between letters) can adjusted with the letter-spacing property Paragraphs

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 15 Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Remember: only works for content enclosed within elements Paragraphs p {font-size:14pt}

CSCE Chapter 3 (Cascading Style Sheets) Indent and line spacing p {text-indent:25pt; line-height:24pt} p {text-indent:12%; line-height:150%} Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Font Families What if not installed on user’s browser? p {font-family: “ Lucida ” } Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Include more than one font families p {font-family:“Lucida”, “Arial”} Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Formatting Fonts Using Styles Warning: multiple fonts may not have the impact you intend User’s display may not include the fonts you specified Common fonts may be the best choice overall Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) You Can Compress Definition p {font-style:italic; font-weight:500; font-variant:small-caps; font-size:14pt; line-height:24pt; font-family:“Lucida”, “Arial”} p {font: italic 500 small-caps 14pt/24pt “Lucida “, ”Arial”} Font Size Bold and Italic and Beyond Paragraph Styles and Font Families The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Do all paragraphs have to be the same? Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Classes are used to create multiple versions of the same basic structure, inheriting characteristics from the parent class, and specifying its own. Previously set properties can be changed to a different value or returned to default by specifying the property value “none”.

CSCE Chapter 3 (Cascading Style Sheets) Tags with Multiple Styles The same type of element can have multiple definitions called “classes” p {text-align:justify; font-weight:bold} p.intro {text-align:center; color:red} Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Tags with Multiple Styles The p.intro class includes the styles of the p class but changes those styles How is this class invoked? Explains why “none” is an option text-transform; font-variant … Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Local Styles Local styles take precedence over other style definitions The text in this paragraph will The text in this paragraph won’t be red Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) No existing tag is quite right. Now what? Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Custom Tags Can create entirely new elements Generic tags: (block level) (inline) Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Custom Tags span {font-size:18pt} Let me make something perfectly clear. Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Classes may be defined for custom tags span.red {color:red} Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) I’m going to get tired of entering style definitions into all my web pages. Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Text-only file Contains style definitions only h2 {color:red} h1 {font-size:24pt} p {text-align:center} p.small {font-size:10pt} No tags needed Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More External Style Sheets

CSCE Chapter 3 (Cascading Style Sheets) External Style Sheets Save in a file with a.css extension css = cascading style sheets Local, internal and external may be present in the same document Local overrides internal Internal overrides external Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) External Style Sheets How to specify external style sheets? Add tag in section Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Possible Problems Problem: older versions of browsers might not recognize style definitions Could use comments: <!-- p {text-indent:25pt; line-height:24pt} --> Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) More Problems XHTML may not recognize this use of comments Solution: use method If older version of browser does not recognize this tag it will ignore it Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More

CSCE Chapter 3 (Cascading Style Sheets) Benito Mendoza 35 Implementing complex style sheets can be a little bit frustrating. Some times is difficult were the syntax errors are. The browser support for styles in general is not uniform. Try out their styles implementation on all the target browsers or stay with the basic styles Creating an Internal Style Sheet Experimenting with Colors Changing the Alignment The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More Last Thing …

CSCE Chapter 3 (Cascading Style Sheets) Exercise Debugging Exercise, p. 81 Correct errors Using Local Styles Creating Custom Tags External Style Sheets The Power of Styles Formatting Fonts Using Styles One Tag, Multiple Styles: Classes & More