Cascading Style Sheets

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 Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Cascading Style Sheets
Cascading Style Sheets
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.
CSS Digital Media: Communication and design 2007.
Today CSS HTML A project.
Introducing CSS CIS 133 mashup Javascript, jQuery and XML 1.
CSS CSS Precise Aesthetic Control. Cascading Style Sheets Though they can be put in HTML header, usually a separate page that the HTML links to Contains.
Very quick intro HTML and CSS. Sample html A Web Title.
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.
Cascading Style Sheets By: Valerie Kuna. What are Cascading Style Sheets? Cascading Style Sheets (CSS) are a standard for specifying the presentation.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
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.
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.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา 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.
Class four: the box model and positioning. is an HTML tag which allows you to create an element out of inline text. It doesn’t mean anything! try it:
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
Unit 20 - Client Side Customisation of Web Pages
Cascading Style Sheets by Pavlovic Nenad by. Presentation Contents  What is CSS?  Why CSS?  Types of Style Sheets  Style Sheets Syntax  Box Formatting.
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 7.
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
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.
1 Cascading Style Sheets
Internet & World Wide Web How to Program, 5/e 1. 2.
WebD Introduction to CSS By Manik Rastogi.
CSS.
Cascading Style Sheets
Cascading Style Sheets (CSS) Internal Style Sheets Classes
Working with Cascading Style Sheets
Cascading Style Sheet.
CS3220 Web and Internet Programming CSS Basics
Cascading Style Sheets™ (CSS)
Semester - Review.
Creating Your Own Webpage
CSS: Cascading Style Sheets
Chapter 6 Cascading Style Sheets™ (CSS)
Cascading Style Sheets
IS 360 Declaring CSS Styles
Chapter 3 Style Sheets: CSS
Web Developer & Design Foundations with XHTML
Cascading Style Sheets
Intro to CSS CS 1150 Fall 2016.
Web Development & Design Foundations with HTML5 7th Edition
Chapter 7 Page Layout Basics Key Concepts
Web Development & Design Foundations with HTML5 8th Edition
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Cascading Style Sheets: Basics
Basics of Web Design Chapter 7 Page Layout Basics Key Concepts
Intro to CSS CS 1150 Spring 2017.
Software Engineering for Internet Applications
DynamicHTML Cascading Style Sheet Internet Technology.
Cascading Style Sheets
Cascading Style Sheets
Cascading Style Sheets™ (CSS)
DynamicHTML Cascading Style Sheet Internet Technology.
CS3220 Web and Internet Programming CSS Basics
Part 1: Cascading Style Sheets
CS3220 Web and Internet Programming CSS Basics
CIS 133 mashup Javascript, jQuery and XML
Cascading Style Sheets
Cascading Style Sheets
Web Programming and Design
Cascading Style Sheets
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets™ (CSS)
Presentation transcript:

Cascading Style Sheets CSS - Cascading Style Sheets language Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents designed for HTML in 1996 CSS1 (1996), CSS2 (1998), CSS Mobile Profile CSS3 (working drafts) browser support (better than for XSL) CSS1 IE5 and IE6 CSS2 Firefox, Netscape 6, IE6 & Opera 6 http://www.w3schools.com/css/css_reference.asp own syntax 20.9.2018 Jaana Holvikivi

CSS rules CSS style rules: h1 {font-size: 32pt; font-weight:bold} each rule starts with a tag name followed by a list of style properties bracketed by { and } tag name defines the element Each style property starts with the property's name, then a colon and lastly the value for this property. When there is more than one style property in the list, you need to use a semicolon between each of them property : value property – i.e. font-size value – i.e. '32 pt' latest rule is valid 20.9.2018 Jaana Holvikivi

Style on HTML pages HTML HEAD STYLEsheet STYLE Javascript file SCRIPT BODY <tag Javascript> Javascript <tag style> 20.9.2018 Jaana Holvikivi

Using inline styles <html> <!-- Exercise 1: inline style --> <head> <title>XML - Inline Styles</title> </head> <body> <p>This text does not have any style applied to it.</p> <!-- The style attribute allows you to declare inline --> <!-- styles. Separate multiple styles with a semicolon. --> <p style = "font-size: 20pt">This text has the <em>font-size</em> style applied to it, making it 20pt.</p> <p style = "font-size: 20pt; color: #0000ff">This text has the <em>font-size</em> and <em>color</em> styles applied to it, making it 20pt and blue.</p> </body> </html> 20.9.2018 Jaana Holvikivi

Internal styles <html> <!-- Exercise 2: internal style --> <head> <title>XML: introduction to CSS </title> <!-- Declaring a style in the header section --> <style type = "text/css"> em { background-color: #8000ff; color: white } h1 { font-family: arial, sans-serif } p { font-size: 110 % } .special { color: blue } </style> </head> <body> <!-- This class attribute applies the .blue style --> <h1 class = "special">Main heading</h1> <p> For st etc. 20.9.2018 Jaana Holvikivi

External styles <html> <head> <title> Linking an external style sheet </title> <link rel = "stylesheet" type = "text/css" href = "style4.css"> </head> <body> .. And so on /* Example: style4.css */ /* External style sheet */ a.nodec { text-decoration: none; } a:hover { text-decoration: underline; color: red; background-color: #ccffcc; } ul { margin-left: 2cm; } li em { color: red; font-weight: bold; } 20.9.2018 Jaana Holvikivi

Cascading Style Sheets Inheritance <body> <div> <h1> <p> <b> 20.9.2018 Jaana Holvikivi

Inheritance <STYLE TYPE="text/css"> BODY {color : red}   H1 {color : blue} p { font-family: Arial, Helvetica, sans-serif; padding: 2px} 20.9.2018 Jaana Holvikivi

Text boxes inline content padding block border margin page block margins 20.9.2018 Jaana Holvikivi

Text boxes padding: 2pt 3 pt 4pt 5pt between frame and content margin: 2pt, 3pt, 4pt, 5pt between boxes (order: top, right, bottom, left) margin-left, margin-right, etc. width: 50%; height: auto size of image float: left /* right */ (makes the box float) clear: both /* left, right*/ (no floating) 20.9.2018 Jaana Holvikivi

Some points of CSS examples in HTML: <span style =”clear: right”>here a non-floating part of text is started. Span is used to delimit a text area for exceptional formatting.</span> div defines a separate paragraph div {text-align: center; margin-bottom: 1em} The z-index property sets the stack order of an element. An element with greater stack order is always in front of another element with lower stack order. in CSS: em refers to the relative size of text 20.9.2018 Jaana Holvikivi

How the browser sets priority for style definitions Styles declared as important by the page creator {color : red !important } Styles declared as important by the user Normal styles by the page creator Normal styles by the user Default styles by the browser if there are no user styles 20.9.2018 Jaana Holvikivi

External information : Pseudo-classes and pseudo-elements normally CSS styles are based on HTML tags and attributes. Sometimes it is not sufficient. CSS introduces the concepts of pseudo-elements and pseudo-classes to permit formatting based on information that lies outside the document tree. Anchor pseudo-class: Links (LINK) are VISITED or ACTIVE Example:  A:link {color : red} A:visited {color : blue} A:active {color : white} The :hover pseudo-class applies while the user designates an element (with some pointing device), but does not activate it. 20.9.2018 Jaana Holvikivi

Using CSS on HTML pages Generalized use Write style definitions to fit several pages, preferably the entire site. If you need page specific styles, use the STYLE attribute inside the document. Scalability Avoid using absolute values for font size, margins, etc. Users can have very different browsers, screen resolutions, window sizes, etc. Use relative measures. 20.9.2018 Jaana Holvikivi

Using CSS on HTML pages Test the styles with different browser versions, Design your pages to work also without style sheet support Browsers behave and render pages in non-standard ways! Select fonts with care people may not have all nice fonts on their PC Don’t push it too far! Not every single element and attribute needs a pre-set value. 20.9.2018 Jaana Holvikivi