Cascading Style Sheets 26 th March. Introduction 1. CSS types 2. Pseudoclasses and pseudoelements 3. Other considerations 4. Worked example.

Slides:



Advertisements
Similar presentations
CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
Advertisements

HTML – A Brief introduction Title of page This is my first homepage. This text is bold  The first tag in your HTML document is. This tag tells your browser.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
กระบวนวิชา 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.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
INTRODUCTORY Tutorial 3 Using CSS to Format Multiple Pages.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
Beginning Web Site Creation: Dreamweaver CS4. XHTMLCSS  Describes the structure  Content  Collection of styles  Formatting body { background-color:
CSE CASCADING STYLE SHEETS CSS Faculty of Computer Science and Engineering.
Cascading Style Sheets Scripting with Style. CSS versus HTML  Ways to format in HTML –HTML Tag extensions –Converting Text to images –Page Layout with.
Cascading Style Sheets 23 rd March. Cascading Style Sheets (CSS) CSS Syntax Linking CSS to XHTML Inheritance & Cascading Order Font Properties Text Properties.
Controlling Page Style: Cascading Style Sheets (CSS) References: 1.Wang, P.S & Katila, S. (2004). A Introduction to Web Design and Programming. CA: Thomson.
CM143 Week 4 Introducing CSS. Cascading Style Sheets A definition for the style in which an element of the webpage will be displayed Border width, colour,
 Missing (or duplicate) semicolons can make the browser completely ignore the style rule.  You may add extra spaces between the properties/values to.
XHTML and CSS Introduction to XHTML and CSS Bharti Patel 1 phones off (please)
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
1 Web Developer Foundations: Using XHTML Chapter 9 Cascading Style Sheet Concepts.
Cascading Style Sheets Part 1 Library and Information Services, University of St Andrews.
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.
CSS Cascading Style Sheets By Garrett Garman. CSS Why use Style Sheets? Separates Appearance and Structure Modularity Quick and Easy changes Flexibility.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
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.
Doman’s Sections Information in this presentation includes text and images from
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.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
Website Development & Management Working with Style Rules Instructor: John Seydel, Ph.D. CIT Fall
Part 1: CSS - Why? - How it works - Writing rules - Examples.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 14, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
Cascading Style Sheets CSS by Pavlovic Nenad by. 2Cascading Style Sheets Presentation Contents What are CSS? What are CSS? History of CSS History of CSS.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
Today’s objectives  Review  CSS | Rules | Declarations  HTML Structure document  Class asignment.
CO1552 – Web Application Development Cascading Style Sheets.
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.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
Tables 23 rd February. What XHTML have we done so far? Hyperlinks & anchors - XHTML supports 3 types of lists:  Ordered – +  Unordered – +  Definition.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
 Use the think diagram … ISP Server.
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.
The Web Wizard’s Guide To DHTML and CSS Chapter 1 A Review of CSS1.
INTRODUCTORY Tutorial 3 Using CSS to Format Multiple Pages.
Cascading Style Sheets
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
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.
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
Copyright © 2006, Jumail, FSKSM, UTM Slide 1 Cascading Style Sheets (CSS)
CSS – 1h. Without stylesheets proprietary HTML extensions making text into images proliferate use of "spacer" GIF images deprecated HTML elements and/or.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Lecture 2: Cascading Style Sheets (CSS) Instructor: Dr. M. Anwar Hossain.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
CSS: Cascading Style Sheets Part II. Style Syntax.
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.
Company LOGO In the Name of Allah,The Most Gracious, The Most Merciful King Khalid University College of Computer and Information System Web pages Development.
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
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.
1 Cascading Style Sheets
WebD Introduction to CSS By Manik Rastogi.
Madam Hazwani binti Rahmat
Presentation transcript:

Cascading Style Sheets 26 th March

Introduction 1. CSS types 2. Pseudoclasses and pseudoelements 3. Other considerations 4. Worked example

Reminder: Inline   Affects individual HTML tag some text

Reminder: Embedded  Affects individual document... p {font-family: Arial, sans-serif;}... some text

Reminder: Separate text file (.css)  e.g. styles.css p { font-family: Arial, Sans-serif; } some text

Reminder: Imported Into HTML url(“styles.css”); Into another style sheet instruction must be first line of url(“styles.css”); /*other stylesheet starts here*/ h1 { font-size: 200%; color: #6b84b5 }

What is wrong with the following pieces of code? 1. p{text-align:center;} p{text-align:center;} 4.h1{text-spacing=“normal”;}

Use inline CSS to style this page

Use embedded CSS to style this page

Order of Precedence 1. HTML formatting instructions (e.g. tags) 2. Inline styles 3. Embedded styles 4. Linked styles 5. Imported styles 6. Default browser styles

Types of CSS styles Styles assigned to a HTML element Class selector styles  Define different styles for one or more HTML elements  Assigned to the class attribute within an HTML element ID selector styles  Define different styles for one and the same HTML element  Assigned to the ID attribute within an HTML element

Class Selector Styles CSS: ….blue {color: #082984}.red {color: #de2131} HTML: … Headline a summary some text …

ID Selector styles CSS … #red_heading {color: red} #summary {color: red} p#conclusion {color: blue} HTML … Headline Summary Conclusion …

What is the Difference between class & id? The difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one. If you have a style that you want to apply several times throughout the document, you need to use a Class. However, it if only want to apply the style once (for instance, to position a particular element, such as a banner) you should use the ID.

Using Pseudoclasses Pseudoclasses are identifiers that are understood by user agents and apply to elements of certain types without the elements having to be explicitly styled Example: A handful of pseudoclasses can be used with anchor elements

Using Pseudoclasses PseudoclassMatch :link :visited :active :hover :focus Unvisited links Visited links Active links The link that the browser pointer is hovering over The link that currently has the user interface focus

Using Pseudoclasses a:link { font-family: Tahoma; color:black; font-size: 10pt; text-decoration:none; } a:visited { font-family: Tahoma; color:black; font-size: 10pt; text-decoration:none; } This definition is in the separate CSS file. Every time a tag is used, the attributes defined in the style sheet are automatically used

Using Pseudoelements Pseudoelements** are another virtual construct to help apply styles dynamically to elements within a document, e.g., :first-line, :first-letter Whenever is used, the first line of the paragraph will be automatically underlined p:first-line {text-decoration: underline} p:first-line {text-decoration: underline} **Pseudo classes are very similar to pseudo elements, but pseudo classes apply the styling rules to the element depending on some state.

Other Text Considerations in CSS Letter & word spacing.normal {letter-spacing: normal; }.normal {letter-spacing: normal; }.tight {letter-spacing: -.2em; }.tight {letter-spacing: -.2em; }.loose {letter-spacing:.2em; } <body> ………… ………… ……</body>

Other Text Considerations in CSS Capitalisation The text-transform property can be used to force capitalisation on elements h1, h2, h3, h4, h5, h6 {text-transform: capitalize}

Colours & Backgrounds Including Background Images p {background-image: url(“gradient.gif”);} p {background-image: url(“gradient.gif”);}

Tables & CSS There are many CSS properties that can be used to control table attributes table td {padding:5x;} table td {padding:5x;} table.attrib-similar { border: outset 1pt;} table.attrib-similar td { border: outset 1pt;} <body>… …</body>

Example from Zeid (Chapter 16) (style)ceol.css(content)seannos.html Web-site

CSS Example seannos.html <html><head> Traditional Irish Music Traditional Irish Music </head>…… External CSS

Ceol.css Explained Part I body{text-align:center;}.titleimg{ background: url('titleimg.jpg') no-repeat; width:770px; height:110px; background-repeat:no-repeat }.menulinks{ font-family: Tahoma; font-size: 10pt; text-align: center; }.mainbody{width:770px;} All text in the body will be centre-aligned Class defined for inserting image used at the top of the webpage. Only used once. Class defined for the horizontal menu items under the title image Class defined for the main text area

Ceol.css Explained Part II h1{ font-family: Tahoma; font-style:bold; font-size: 10pt; text-align: left; }a:link{ font-family: Tahoma; …..}a:visited{ …..} All text in tags will have the following attributes A link will automatically have the following characteristics If a link has been visited already it will take on the following characteristics

Seannos.html Part I <body> </div> HOME | …… HOME | ……</div> The Living Tradition The Living Tradition PO Box 1026 PO Box 1026 ….. Articles Index Articles Index ….. Newletter Newletter …..<p>..</div>

Seannos.html Part II <body>…. Sean-nos singing - A Bluffers Guide Sean-nos singing - A Bluffers Guide - by Anthony McCann Issue 24 June/July '98 - by Anthony McCann Issue 24 June/July '98 <p> One of the Irish papers once told of how, while on a lecture tour,.. tour,.. </div> </div> </div> </div></div></div></body>

Exercise Write a web page to print 1 line of bold, blue text using:  Inline CSS  Embedded CSS  External CSS

Exercise Inline text goes here Embedded ….. body {color: blue; font-weight: bold} ….

Exercise External ….. …. body {color: blue; font-weight: bold} CSS File HTML File

Reference Steven M. Schafer (2005), HTML, CSS, JavaScript, Perl, and PHP Programmer's Reference, Hungry Minds Inc,U.S. Dan Cederholm (2005), Bulletproof Web Design: Improving Flexibility and Protecting Against Worst-Case Scenarios with XHTML and CSS, New Riders. Ibrahim Zeid (2004), Mastering the Internet, XHTML, and Javascript