Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.

Slides:



Advertisements
Similar presentations
Intro to HTML. HTML HTML = HyperText Markup Language Used to define the content of a webpage HTML is made up of tags and attributes Content.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
Cascading Style Sheets (CSS) “Styles” for short. Pg. 418.
Cascading Style Sheets
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.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
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.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
Cascading Style Sheets Controlling the Display Of Web Content.
Using Cascading Style Sheets CSS Structure. Goals Understand how contextual, class and ID selectors work Understand how contextual, class and ID selectors.
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.
JMD2144 – Lesson 5 Web Design & New Media. ‘Div’ide and conquer One of the most versatile structure tags available is the.. tag Short for ision, it allows.
Basics of HTML.
Cascading Style Sheet. What is CSS? CSS stands for Cascading Style Sheets. CSS are a series of instruction that specify how markup elements should appear.
© 2012 Adobe Systems Incorporated. All Rights Reserved. LEARNING THE LANGUAGE OF THE WEB INTRODUCTION TO HTML AND CSS.
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,
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
STYLING THE WEBSITE - EXTERNAL CSS BY JORGE MARTINEZ.
 ult.htm ult.htm  This website illustrates the use of CCS (style sheets)
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
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.
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.
Using Cascading Style Sheet As you create more web pages, you may wish to impose a consistent look for all of your web pages or for group of related pages.
Css. Definition Cascading style sheet (CSS) Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
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.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
DHTML. What is it? Dynamic HTML. Not a standard unlike HTML or Java It is a term applied by both Netscape and Microsoft to a collection of technologies.
HTML GUIDE Press F5 and then Click on the links on the left to get to the section you want Section 1: Getting Started Section 2: Moving Banner Section.
Cascading Style Sheets Creating a Uniform Site. Style Sheets  Style sheets are used for conformity on a web page or web site.  Style sheets eliminate.
Cascading Style Sheets
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.
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.
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 I Embedded Style Sheets. Page Design ICSS 2Instructor: Sean Griffin What is a Style Sheet? A style sheet is a text file that contains.
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
External Style Sheets Exploring Computer Science – Lesson 3-6.
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.
Style Sheets. Coding Style Sheets  Style sheets use RULES to create the style  A selector (a tag or user-defined style name)  and then declarations.
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.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Chapter 4 Frames and Cascading Style Sheets. Frames Frames divide a browser window into two or more separate pieces or panes, with each pane containing.
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…
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.
Cascading Style Sheets Part 1 1 IT 130 – Internet and the Web.
Internet & World Wide Web How to Program, 5/e 1. 2.
Getting Started with CSS
CSS: Cascading Style Sheets
>> Introduction to CSS
IS 360 Declaring CSS Styles
Madam Hazwani binti Rahmat
CX Introduction to Web Programming
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheets - Building a stylesheet
Intro to CSS CS 1150 Spring 2017.
Cascading Style Sheets™ (CSS)
Web Design and Development
Cascading Style Sheets - Building a stylesheet
Presentation transcript:

Cascading Style Sheets (CSS) 1

 What is CSS?  Why CSS?  How to write a CSS? 2

A Style sheet is a list of rules that determine the appearance of the elements of a web page. The term cascading refers to the styles on a Cascading Style sheet “cascade”(pass,connect) into other WebPages, and controls the fonts, spacing, colors, backgrounds and other display properties of web pages. 3 What is a Style Sheet?

Cascading Style Sheets(CSS) are great tools for separating HTML content from HTML display instead of having to code style settings in HTML for a Web page you can create a stylesheet that meets your needs and include that stylesheet. A centrally located stylesheet can be referenced from all the HTML pages for a website to ensure the same standardized look and feel for the entire site. 4 Why CSS?

If the stylesheet is centrally located, changing a body style from one font to another, a heading from one color to another, changes the display for that tag across the entire site. Style sheets not only allow you to specify the appearance of individual web page, but can also be used to provide a whole web site with a consistent overall look. 5 Why CSS?

Suppose you want all bold text to appear in red. My First Style Sheet B {color: red} I am bold and red 6 Writing your first style sheet

In this example, there is a single rule B {color:red} This rule has two parts. The first part of the rule, B, is called selector. A selector is used to select the elements in a web page that affects The second part of the rule is called the declaration. A declaration contains a property and a value. One or more selectors are used to pick out elements in the web page. The selector is followed by a single space. The property and value are separated by a colon and wrapped in {}. 7

There are three ways to link Style Sheets to HTML, categorised as follows 1) Inline Style Sheets 2) Embedded Style Sheets 3) Linked Style Sheets 8 Ways to Link Style sheets to HTML

Eg. Inline Style Sheet I am bold and red 9 Inline Style Sheet

Eg. Embedded Style Sheet B {color: red} I am bold and red 10 Embedded Style Sheets

You can place your style rules in separate files and apply the same rules to multiple documents. B {color:red} Create a new file that contains nothing but this rule.You can save the file with any name but the extension be given as.css, for example: save the file as mystyle.css. 11 Linked Style Sheets

Eg. Linked Style Sheet I am bold and red 12 Linked Style Sheets

The link tag has four attributes. The first attribute, TYPE specifies the MIME type of the linked file. Cascading style sheets have the MIME type “text/css”. The HREF attribute points to the file containing the style sheet. The REL attribute informs the browser that the linked file is a stylesheet. The TITLE attribute gives the style sheet a title. 13 Linked Style Sheets

You can apply a style rule to almost any HTML tag. Suppose you want all the text list to appear in red. Future Point <!- - B {color:red} OL {color:red} -- > I am bold and red I am red So am I 14 In this example, the single rule OL {color:red} affects the color of every item listed.If you have more than one list, the items in those lists appear in red as well. Both of the rules in this stylesheet have the same effect on the elements they select. The first rule makes everything contained in tag red; second rule makes everything contained in every ordered list red. To save typing, you can combine two rules into one: B, OL {color: red} Adding Styles to an HTML Tag

Adding Styles to a class of HTML tags Suppose you need to apply a rule to certain paragraphs in a web page, but not to all of them. For e.g., you may want the first paragraph to appear in 24-point type and the second paragraph to appear in 14-point type. To do this with style sheets, you need a way to distinguish between different instances of the tag. Using a special attribute in HTML we can achieve this. Every HTML tag has a CLASS attribute. The class attribute is used to divide tags into different classes. 15 Class Example <! – P.TheFirstClass {font-size: 24pt} P.TheSecondClass {font-size: 14pt} -- > I am the first paragraph and I am formatted with a 24 point font. I am the Second paragraph and I am formatted with a 14 point font. The text contained within the tags appears with different font sizes. The two fonts are distinguished by their respective CLASS attributes.

Adding Styles to Classes Till now we have seen, style sheet rules have been associated only with particular types of HTML tags. But you also can associate a rule with a class that is not associated with any particular tag. 16 Class Example I am bold and I am formatted with a 24 point font. I am in the paragraph and I am formatted with a 24 point font. Both the tag and the tag are associated with the same class. The text contained in both the tag and the tag is formatted with a 24-point font. The rule is not associated with any type of HTML tag. Instead the rule is associated with the class FreeClass. Note: Do not forget to add the initial period when specifying the class selector in the rule. If you forget the period, the browser thinks you are attempting to select an HTML tag for the rule rather than a class.

Adding styles to HTML tags Depending on Context Suppose you want bold text in a list to appear in the Courier typeface. However you don’t want text to appear in Courier outside the list or when the text is not bold. A number of ways you can do this. Using style sheets, you could create a special class and associate with only tags that appear in lists. In another way, we can achieve the same effect, by specifying that a rule should be applied only in certain contexts. For e.g., you can define a rule that effects text only when the text appears in bold and a list, but not in any other contexts. 17 Context Example I am bold but not in the courier typeface I am plain, but I am bold and use Courier! Yes, but I am bold and use Courier as well! The selector contains two HTML tags, but the tags are not separated by commas. The selector is applied only when a tag is contained within a tag. Text contained within the tag but not appearing in a list isn’t governed by this rule.

Examples BODY {font:10pt Arial,verdana; background: url(test.gif); margin-left: 0.5in; margin-right: 0.5in } P {font-family: verdana,arial; font-size: 12pt;font-weight: bold; font- style: italic ;color:green} P {font: bold italic 12pt verdana,arial} 18