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

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.
Building a Website: Cascading Style Sheets (CSS) Fall 2013.
CSS(Cascading Style Sheets )
กระบวนวิชา 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.
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
4.01 Cascading Style Sheets
Cascading Style Sheet (CSS)
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.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
INTRODUCTION TO CSS. OBJECTIVES: D EFINE WHAT CSS IS. K NOW THE HISTORY OF CSS. K NOW THE REASON WHY CSS IS USED. CSS SYNTAX. CSS ID AND CLASS.
CSS Basic (cascading style sheets)
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
DIV, Span, CSS.
1 CSS محمد احمدی نیا 2 Of 21 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements 
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.
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.
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.
Introduction To CSS. Lesson 1: History of CSS CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. There were.
1 Cascading Style Sheets
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.
WebD Introduction to CSS By Manik Rastogi.
CSS.
Cascading Style Sheets
Cascading Style Sheet.
HTML WITH CSS.
CSS Cascading Style Sheets
CSS for Styling By Jinzhu Gao.
Web Development & Design Foundations with XHTML
4.01 Cascading Style Sheets
( Cascading style sheet )
Cascading Style Sheet.
HTML WITH CSS.
CSS Cascading Style Sheets Brief Introduction
Introduction to the Internet
Cascading Style Sheets
Madam Hazwani binti Rahmat
Chapter 3 Style Sheets: CSS
Web Developer & Design Foundations with XHTML
Cascading Style Sheets
Cascading Style Sheet (CSS)
Cascading Style Sheets
CASCADING STYLE SHEET CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
CSS Cascading Style Sheets
Website Design 3
Cascading Style Sheets - Building a stylesheet
Introduction to Web programming
The Internet 10/13/11 The Box Model
Cascade Style Sheet Demo W3Schools. com: w3schools
Stylin’ with CSS.
محمد احمدی نیا CSS محمد احمدی نیا
Web Programming– UFCFB Lecture 11
What are Cascading Stylesheets (CSS)?
Cascading Style Sheets
Cascading Style Sheets (CSS)
Tutorial 3 Working with Cascading Style Sheets
Part 1: Cascading Style Sheets
Cascading Style sheet. What is CSS?  CSS stands for Cascading Style Sheets  Cascading: refers to the procedure that determines which style will apply.
Cascading Style Sheets - Building a stylesheet
Stylin’ with CSS.
Cascading Style Sheets
4.01 Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
Stylin’ with CSS.
CGS 3066: Web Programming and Design Fall 2019
Presentation transcript:

Cascading Style Sheets CSS Cascading Style Sheets Mr. A. Rozario B. Voc. (SD & SA) Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS CSS stands for Cascading Style Sheets Styles define How to display HTML elements CSS Saves a Lot of Work! CSS defines How HTML elements are to be displayed Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file! Prepared by Mr. A. Rozario

Understanding Style Rules A Style Rule is composed of two parts: a selector and a declaration. Selector Declaration P{color: red;} The Selector indicates the element to which the rule is applied. The Declaration determines the property values of a selector. Prepared by Mr. A. Rozario

Understanding Style Rules The Declaration determines the property values of a selector. The Value expresses specification of a property, such as red for color, arial for font family, 12 pt for font-size, and is followed by a semicolon (;). Property Value P{color: red;} Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS CSS declarations always ends with a semicolon, and declaration groups are surrounded by curly brackets: p {color:red;text-align:center;}To make the CSS more readable, you can put one declaration on each line, like this: Example p{color:red; text-align:center; } CSS Comments A CSS comment begins with "/*", and ends with "*/", like this: /*This is a comment*/ p{ text-align:center; /*This is another comment*/ color:black; font-family:arial; } Prepared by Mr. A. Rozario

CSS Syntax: Selector Strings Element Type Selector / Single element type: Group Selector / Multiple element types: Universal Selector / All element types: Id Selectors / Specific elements by id: Class Selectors .p {font-weight: bold;} Prepared by Mr. A. Rozario

The id and class Selectors In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class". The id Selector The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". The style rule below will be applied to the element with id="para": Example #para {text-align:center; color:red;} Prepared by Mr. A. Rozario

The id and class Selectors The class Selector The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for any HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "." In the example below, all HTML elements with class="center" will be center-aligned: Example .center { text-align:center; } In the example below, all p elements with class="center" will be centeraligned: p.center {text-align:center;} Prepared by Mr. A. Rozario

Three Ways to Insert CSS Inline style Internal / Embedded style sheet External style sheet Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario Inline Styles <p style="color:red;margin-left:20px">This is a paragraph.</p> Multiple Style Sheets If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet. For example, an external style sheet has these properties for the h3 selector: h3 { color:red; text-align:left; font-size: 8pt; } And an internal style sheet has these properties for the h3 selector: text-align:right; font-size:20pt; Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario Inline Styles If the page with the internal style sheet also links to the external style sheet the properties for h3 will be: color: red; text-align: right; font-size: 20pt; The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet. Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario Internal Style Sheet An internal style sheet should be used when a single document has a unique style. <head> <style type="text/css"> hr {color:red;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} </style> </head> Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head tag section: <head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below: hr {color:red;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Text Setting the text color Property - Value Color: rgb|hexa|red; • Alignment of text pro Text-align: center|left|right|justify; • Indentation of text • Decoration of text • Sets the spacing between characters • Sets the spacing between words • Sets the spacing between lines of text • Preserving white-space and line breaks • Text wrapping inside an element • Vertical alignment of an image inside text Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Text Formatting Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Text - Color Font color specified by color property Two primary ways of specifying colors: Color name: black, gray, silver, white, red, lime, blue, yellow, aqua, fuchsia, maroon, green, navy, olive, teal, purple red/green/blue (RGB) values Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Text - Color Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS FONT Sets the font of a text Sets the size of the font Sets the style of the font Sets the variant of the font Sets the boldness of the font Setting the all font properties in a single declaration - The font shorthand property Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties The font family of a text is set with the font-family property. The font-family property should hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font. p{font-family:"Times New Roman", Times, serif;} A font family is a collection of related fonts (typically differ in size, weight, etc.) Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties generic fonts are system- specific Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties Set Font Size With Em To avoid the resizing problem with Internet Explorer, many developers use em instead of pixels. The em size unit is recommended by the W3C. 1em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px. The size can be calculated from pixels to em using this formula: pixels/16=em Example h1 {font-size:2.5em;} /* 40px/16=2.5em */ h2 {font-size:1.875em;} /* 30px/16=1.875em */ p {font-size:0.875em;} /* 14px/16=0.875em */ Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties Many properties, such as font-size, have a value that is a CSS length All CSS length values except 0 need units Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties Computed value of font-size property Other ways to specify value for font-size: Percentage (of parent font-size) Absolute size keyword: xx-small, x-small, small, medium (initial value), large, x-large, xx-large User agent specific; should differ by ~ 20% Relative size keyword: smaller, larger Relative to parent element’s font Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties Text is rendered using line boxes Height of line box given by line-height Initial value: normal (i.e., cell height; relationship with em height is font-specific) Other values (following are equivalent): Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties font shortcut property: Initial values used if no value specified in font property list (that is, potentially reset) Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario FONT Properties font shortcut property: specifying line-height (here, twice cell height) any order size and family required, order-dependent Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS LINKS Style different states of a link Remove the default underline from hyperlinks Remove the dotted outline from hyperlinks Create link boxes Image rollover Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS LINKS Links can be style with any CSS property (e.g. color, font-family, background-color). Special for links are that they can be styled differently depending on what state they are in. The four links states are: a:link - a normal, unvisited link a:visited - a link the user has visited a:hover - a link when the user mouse over it a:active - a link the moment it is clicked Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS LINKS Example a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */ a:link {text-decoration:none;} a:visited {text-decoration:none;} a:hover {text-decoration:underline;} a:active {text-decoration:underline;} a:link {background-color:#B2FF99;} a:visited {background-color:#FFFF85;} a:hover {background-color:#FF704D;} a:active {background-color:#FF704D;} Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Box Model Every rendered element occupies a box: Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Box Model Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Box Model Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Box Model Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario CSS Box Model Prepared by Mr. A. Rozario

Prepared by Mr. A. Rozario Thank You Prepared by Mr. A. Rozario