CO1552 – Web Application Development 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

CSS Cascading Style Sheets. Contents{ 1. What is CSS? 1. A Brief History of CSS 2. Why to use Styles? 2. Syntax 3. Cascading Order 4. Examples of Properties.
CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style.
Cascading Style Sheets
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
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.
กระบวนวิชา 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.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Cascading Style Sheets Please use speaker notes to get complete information! Cascading Style Sheets.
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:
Prepared by ackoo Styli n g your page (font type, font size, colors, text decoration, alignment, set margin, table padding, etc.) References: W3Schools.
Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage.
Controlling Page Style: Cascading Style Sheets (CSS) References: 1.Wang, P.S & Katila, S. (2004). A Introduction to Web Design and Programming. CA: Thomson.
Cascading Style Sheet (CSS) Instructor: Dr. Fang (Daisy) Tang
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,
Computing Concepts: CSS. Aims  To understand the uses of css  To understand the different types of css  To be able to create a css file  To be able.
Using Cascading Style Sheets (CSS) Dept. of Computer Science and Computer Information CSCI N-100.
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
The Characteristics of CSS
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.
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
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.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
Working with Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 5.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
Cascading Style Sheets in.NET Lilian Kiilu, Client/Server & Web Applications, Coms 463/563, Section 1pm, Fall 2005, November 16 th 2005.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Cascading Style Sheets Class 2, Lecture 2 Rachel A Ober
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
IS1825: Developing Multimedia Applications for Business Lecture 1: Introduction to CSS Rob Gleasure
CSS Cascading Style Sheets. CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
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.
Designing Web Pages The case for CSS. The Power of CSS css Zen Garden
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.
CSS Cascading Style Sheets *referenced from
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.
Basic Webpage Design Cascading Style Sheet (CSS).
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
Cascading Style Sheets Using HTML. What are they? A set of style rules that tell the web browser how to present a web page or document. In earlier versions.
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
4.01 Cascading Style Sheets
CX Introduction to Web Programming
Cascading Style Sheet (CSS)
CASCADING STYLE SHEET CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Introduction to Cascading Style Sheets (CSS)
Web Programming– UFCFB Lecture 11
Working with Cascading Style Sheets (CSS)
Working with Cascading Style Sheets (CSS)
What are Cascading Stylesheets (CSS)?
Web Design and Development
4.01 Cascading Style Sheets
Presentation transcript:

CO1552 – Web Application Development Cascading Style Sheets

What is a Style Sheet? XHTML only handles the structure of the page A set of instructions to the browser which tell it how to display the content There is a set order (hierarchy) in which the styles are interpreted

Cascading Order Generally speaking all the styles will "cascade" by the following rules, where number 4 has the highest priority because it is closest to the text being described: 1. Browser’s default Style Sheet 2. External Style Sheet Created by you and called from the HTML page 3. Internal Style Sheet Created by you inside the tag and called 4. Inline Style Created by you and placed inside HTML element

External style sheet Contains information for formatting any number of pages Can be used (referred to) over and over Example: ex1.css

Link to an external style sheet <link rel="stylesheet" type="text/css" href="ex1.css" /> Any H1 heading is 36 pt Any H2 heading is blue Any paragraph will have a left margin of 50 pixels This is the style sheet file (ex1.css): body {background-color: yellow} h1 {font-size: 36pt} h2 {color: blue} p {margin-left: 50px} Notice that the CSS file has no HTML tags there is no space between a value and its unit (eg, “36” and “pt”, “50” and “px”)

Internal style sheet Should be used when a single page needs a unique style. Over-rides an external style sheet Define in the section by using the tag hr {color: sienna} p {margin-left: 20px} body {background-image: url("images/back40.gif")} Don’t use internal style sheets for multiple pages – use an external one. WHY?

An in-line style Defines a very local change of style Over-rides external and internal style sheets Loses many of the advantages of style sheets by mixing content with presentation Neither more or less effective than HTML formatting Just as annoying to maintain, when you want to make changes! This is a brown paragraph.

What style will be used … when there is more than one style specified for an HTML element?

Principles of styles An inline style (inside an HTML element) has the highest priority it will override every other style, whether declared inside the tag, in an external style sheet, or in a browser’s style sheet (a default value).

An example (part 1) An external style sheet attributes these properties to the HTML selector: h3 { color: red; text-align: left; font-size: 8pt } Write down these properties under the heading “external”

An example (part 2) An internal style sheet has these properties for the h3 selector: h3 { text-align: right; font-size: 20pt } Write down these properties under the heading “internal” Question: If the page with the internal style sheet also links to the external style sheet, the properties for h3 on that page will be?? Answer >>

An example (answers, 3) The properties for h3 will be: color: red; text-align: right; font-size: 20pt The colour is inherited from the external style sheet The text-alignment and the font-size are replaced by the internal style sheet The internal style sheet does not mention colour and so cannot change it.

Styles in use Here is a style defined in the head of a HTML page:. margin {margin-top: 5cm} This is a paragraph with a top margin of 5cm

Styles in use: external file Here is a style defined in an external file, ex1.css. blue_med { font-family: Arial, Helvetica, sans-serif; font-size: medium; font-style: normal; color: #000066; margin-left: 50px; padding-right: 50px; padding-left: 50px; }

Styles in use: external file Style sheets may be quite long and contain definitions of many styles Note that a user-defined style name starts with a dot. small { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small; } A regular HTML tag is redefined without a dot td { font-family: Georgia, Times New Roman, Times, serif; }

Styles in use: external file The file ex1.css is called by writing the following line in the section of any page: "

This is how the style is used In a page linked by the previous line in its head section to the file ex1.css, This is a paragraph which is blue, in Arial font and medium sized Or a paragraph of blue text another paragraph of blue text Or Hello World, my sky is blue!

Summary (1) A style sheet can be Local (in-line) Nearest to object Most influential Very similar to presentational HTML Has to be applied to sections of text individually Internal (in the ) Applies to one whole page Subordinate to a local style but over-rides an external style Has to be applied to each page individually

Summary (2) External (in a.css file) One file can influence as many pages as refer to it Overridden by local/inline and internal styles (IF you use them) Very efficient and easy to maintain Set by the browser Applies if you don’t use any other presentation methods eg “Times New Roman, small, left aligned and black” for paragraph text. Can be over-ridden by local, internal and external styles

Practicals: 1 Try applying manual formatting to some text in Dreamweaver Watch how the style is generated as a local file in the head of the page and automatically named “style 1” Edit the styles by amending the description in the head Test in Explorer or Netscape

Practicals 2: Plan your own site From your assignment 1 designs, you should be able to specify some styles you want to use on your site Make a list of at least 3 styles you need, and specify their attributes, eg: Background image or colour Text attributes such as font weight, font family, font size Alignment and indents Borders Boxes

Create your styles in NotePad Save your styles in a style sheet file Refer to the HTML notes or to W3Schools to get your CSS descriptions right We will be creating a site for your assignment, so: Store the style sheet in the area you want to use for your assignment site Make a folder for it if you haven’t already done so Test the file Call it from the head of a page you have created, and by applying the classes to sections of your file Save and test in Explorer or Netscape