Doing It With Style Style Sheets: Separating Form from Function.

Slides:



Advertisements
Similar presentations
Cascading Style Sheets
Advertisements

CSS-Formatting Review Cascading Style Sheets addstyle to your HTML web pages.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets (CSS) “Styles” for short. Pg. 418.
Cascading Style Sheets
Today CSS HTML A project.
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
1 Styles and CSS David Douglas Sam M. Walton College of Business, University of Arkansas “Connecting scholarship and research with business practice”
Part 2 Introduction to CSS. CSS Syntax – class selector 1 With the class selector you can define different styles for the same type of HTML element. You.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
CSS. CSS, or Cascading Styles Sheets, is a way to style HTML. Whereas the HTML is the content, the style sheet is the presentation of that document.
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.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
Cascading Style Sheets. Slide 2 Lecture Overview Overview of Cascading Style Sheets (CSS) Ways to declare a CSS CSS formatting capabilities New features.
1 Creating Web Pages Part 3. 2 CASCADING STYLE SHEETS (CSS): What exactly are they? Set of rules that define how a web browser should display an HTML.
LBSC 690: Session 6 CSS, XML/XSLT Jimmy Lin College of Information Studies University of Maryland Monday, October 15, 2007.
4.01 Cascading Style Sheets
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.
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,
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
Cascading Style Sheets Dreamweaver. Styles Determine how the HTML code will display Determine how the HTML code will display Gives designers much more.
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
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)
INTRODUCTION TO HTML5 CSS Styles. Understanding Style Sheets  HTML5 enables you to define many different types of content on a web page, including headings,
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.
CSS – Presentation of Information. Types of Style Sheets External Embedded h1{color:red; font-family: Arial;} Inline Text is here.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Working with Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 5.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
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.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
Cascading Style Sheets Part 1. CSS vs HTML HTML: Originally intended to markup structure of a document (,...,,,,,...) CSS Developing technology, CSS1,
Cascading Style Sheets Dreamweaver. Styles Determine how the HTML code will display Determine how the HTML code will display Gives designers much more.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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. Source W3Schools
DYNAMIC HTML What is Dynamic HTML: HTML code that allow you to change/ specify the style of your web pages. Example: specify style sheet, object model.
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,
How to… Cascading Style Sheets. How to Insert a Style Sheet When a browser reads a style sheet, it will format the document according to it. There are.
Intro to CSS Christy. What is CSS?  Cascading Style Sheets  Separates content from presentation  Defines how to display HTML elements  Provides control.
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.
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
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…
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.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
Getting Started with CSS
4.01 Cascading Style Sheets
>> Introduction to CSS
IS 360 Declaring CSS Styles
>> CSS Rules Selection
Website Design 3
Cascading Style Sheets - Building a stylesheet
Introduction to Cascading Style Sheets (CSS)
Web Design and Development
Cascading Style Sheets - Building a stylesheet
4.01 Cascading Style Sheets
Presentation transcript:

Doing It With Style Style Sheets: Separating Form from Function

First, A Little History … When HTML was first developed, there were no GUI browsers; Result: no need for fancy formatting HTML was originally developed to distribute information – little attention was paid to the form of that information

As Time Went By … More & more GUI browsers were invented People wanted more from their web pages HTML evolved to include formatting tags

RESULT: Bloated Pages! HTML scripts became bogged down with tons of formatting tags Extra tags required more disk space

Style Sheets to the Rescue! Separated form from function Reduced file size of HTML scripts Introduced portable code

What can styles do for us? Make our code portable (write once, apply everywhere) Continuity: make pages across websites look the same Reduce code! Allow us some room for “customized” styles

Three Main Types of Styles Used at the tag-level Usually applied to individual tags or groups of tags Similar to container Can “pollute” a script with extraneous code Best used to override higher-level styles

Three Main Types of Styles Defined in the container Configures styles for a SINGLE web page Generally used to override External Style Sheets or when a style is going to be used only on a single page

Three Main Types of Styles Defined in another document with an extension of “.css” Configures styles for multiple web pages Highest level of style

Style Rules Styles are defined according to rules The general* format is: - There are some exceptions to this. Inline styles use a slightly different syntax selector { property:value } Declaration

Style Rules selector { property:value } The selector is usually the HTML tag to which a style will apply. Example: p The property is the attribute being changed. Example: font-family The value represents what the new look the property will take. Example: Arial

Style Rules - Example p { font-size:14pt }

Style Rules - Syntax p { font-family:”Arial Narrow”, Arial,Tahoma,sans-serif } Multiple values can be assigned using commas:

Style Rules - Syntax p {font-size:14pt; font-color:red } You can apply many styles to the same selector Declarations are separated with semi-colons:

Style Rules - Syntax p,li {font-size:14pt; font-color:red } You can apply styles to many different selectors Selectors are separated by commas:

Style Rules - Syntax li em {font-size:14pt; font-color:red } You can apply styles given certain conditions using contextual selectors Contextual selectors are separated by a space: This means that containers which are also encapsulated within a container will have a font-size of 14 points and a font color of red.

Style Rules - Syntax li em, h2 b { font-size:14pt; font-color:red } You can group multiple contextual selectors using commas to separate:

Defining a Class You can create “custom” styles to apply based on unique identifying attributes These “custom” styles are called classes Classes are referenced by attributes in HTML tags

Defining a Class p.myClass { font-family:Arial; font-color:red } Classes can be defined for individual tags:

Defining a Class.myClass { font-family:Arial; font-color:red } Or, classes can be defined for use in many tags:

Referring to a Class in HTML This is a line of text to which a style has been applied. References to a class are made in individual HTML tags:

Extending HTML for Style Sheets Hi There! This is a line of text to which a style has been applied. The … container is used to apply styles to block-level elements:

Extending HTML for Style Sheets Mary had a little lamb, little lamb, little lamb. The … container is used to apply styles to groups of characters:

The External Style Sheet A list of rules (no other syntax except for rules) Saved with a file extension of “.css” 644 permissions (just like an HTML document) Saved as a straight-text file (ASCII file) Highest-Level Style

The External Style Sheet - Example h1{font-family:Arial; font-size:42pt } p{font-family:Arial; font-size:12pt } li{font-family:Verdana; font-size:10pt }

Referencing the External Style Sheet External style sheets are linked to an HTML document in the container:

The Embedded Style Sheet A list of rules (no other syntax except for rules) Defined in the container of an HTML document Embedded styles trump external styles, but are subservient to all other styles Usually contained within an HTML comment

The Embedded Style Sheet - Example

The Inline Style Rules applied to individual tags Defined at the tag level Inline styles trump external embedded styles, but are subservient to HTML tags Use them sparingly!

The Inline Style - Example A style has been applied to this paragraph of text.

Inheritance Styles are inherited from parent-level styles to child-level styles Example: An inline style inherits the properties of an embedded style and an external style External Embedded Inline Inheritance Flows This Way

Conflicting Styles When styles conflict, the more specific style will have more weight Default Browser Settings User-Defined Settings External Styles Embedded Styles Inline Styles HTML Tag Attributes More Weight

Questions?