Introduction to Cascading Style-sheets (CSS) Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 1.

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

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
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.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
4.01 Cascading Style Sheets
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
CSSMR.Mostafa badr1. Lesson 3 Creating an Style Sheet Lesson 2 Structure of the Style Lesson 1: What Cascading Style Sheets are?
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.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
STYLING THE WEBSITE - EXTERNAL CSS BY JORGE MARTINEZ.
 ult.htm ult.htm  This website illustrates the use of CCS (style sheets)
Chapter 3 Working with Text and Cascading Style Sheets.
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
Page Layout Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Adding Image, audio and video files to web pages Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
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.
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.
CSS Basic (cascading style sheets)
Form Tag How to use Form Tag Something NEW ? PARAMETER Attribute NAME Specifies the name for a form To specify which form to submit with JavaScript, this.
Introduction to HTML 1 Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
INTRODUCTION TO CSS. TOPICS TO BE DISCUSSED……….  Introduction Introduction  Features of CSS Features of CSS  Creating Style Sheet Creating Style Sheet.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Text and 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.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
HTML FORMS Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 1.
CSS properties Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
HTML Links and navigation Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Practice for Chapter 3: Assume that you are a freelance web designer and need to create a website to promote your freelance company.
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.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
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.
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.
Working with Cascading Style Sheets
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Getting Started with CSS
4.01 Cascading Style Sheets
>> Introduction to CSS
Cascading Style Sheets
Madam Hazwani binti Rahmat
Using Cascading Style Sheets Module B: CSS Structure
CASCADING STYLE SHEET CSS.
Website Design 3
Cascading Style Sheets - Building a stylesheet
CS134 Web Design & Development
Web Programming– UFCFB Lecture 11
Web Design and Development
Web Design & Development
Cascading Style Sheets - Building a stylesheet
4.01 Cascading Style Sheets
Presentation transcript:

Introduction to Cascading Style-sheets (CSS) Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 1

Outline Understand the basic concept of CSS Understand the differences among inline, internal and external style sheets Understand how to declare a style Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 2

1. Cascading Style Sheet All web pages can be broken down into bucketed content areas These areas can be updated by changing the code on every page - or - By using cascading style sheets! Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 3

1.1 Cascading style sheets Created by Hakon Lie of MIT in 1994 Has become the W3C standard for controlling visual presentation of web pages Cascading style-sheets are powerful mechanism to add style to web document Enforce standards and uniformity Create dynamic effects Works by allowing you to specify rules Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 4

1.2 Advantages of Style Sheets Saves time Easy to change Keep consistency Give you more control over layout Use styles with JavaScript Make it easy to create a common format for all the Web pages Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 5

2. Writing Style Sheets In-line styles Embedded/internal styles External style sheet Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 6

2.1 In-line Styles Inline styles – Add styles to each tag within the HTML file – Use it when you need to format just a single section in a web page – Style attribute is used to add style Example – IU Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 7

2.1 In-line Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 8 Heading with no style Style attribute Color setting Font size setting

2.1 In-line Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 9 Heading with no style CSS styled heading

2.2 Internal Styles A style is applied to the entire HTML file Use it when you need to modify all instances of particular element (e.g., h1) in a web page Example h1 {color:red; font-family:sans-serif} Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 10

2.2 Internal Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 11 Start of style block Tag Color setting Font family Font size End of style Simple heading

2.2 Internal Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 12

2.3 External Styles An external style sheet is a text file containing the style definition (declaration) Use it when you need to control the style for an entire web site Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 13

2.3 External Styles… Open a new blank document in Notepad Type style declarations – h1 {color:red; font-family:calibri;} Do not include tags Save the document as filename.css Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 14

2.3 External Styles… Open an HTML file Between and add – URL is the file.css Relation_type=“stylesheet” Link_type=“text/css” Save this file and the.css file in the same web server directory Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 15

2.3 External Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 16 Style declaration File is saved with mystyle.css name

2.3 External Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 17 Style-sheet is included Heading

2.3 External Styles… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 18

2.4 Style Sheet Strategies Wherever possible, place your styles in external style sheets At the top level of your web site: define a default global.css style sheet Refine styles at sublevels with a section.css style sheet Try to avoid using styles in tags Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 19

3. CSS Syntax Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 20

3.1 Defining a CSS Rule CSS works by allowing you to associate rules with the elements that appear in a web page These rules govern how the content of those elements should be rendered Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 21

3.1 Defining a CSS Rule… A rule consists of – A selector: element or elements the declaration applies to – Declaration: how the elements referred to in the selector should be styled property: which is the property of the selected element value: which is a specification for this property Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 22

3.2 Using Id,s Use an id to distinguish something, like a paragraph, from the others in a document The id selector is used to specify a style for a single, unique element Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 23

3.2 Using Id,s… Create a style Id: – #id_name {style attributes and values} Use a style Id: – Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 24

3.2 Using Id,s… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 25

3.2 Using Id,s… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 26

2.3 Using Classes HTML and XHTML require each id be unique– therefore an id value can only be used once in a document You can mark a group of elements with a common identifier using the class attribute Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 27

2.3 Using Classes… To create a class – tag.class_name {style attributes} or –.class_name {style attributes} To apply a style – IU Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 28

2.3 Using Classes… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 29

2.3 Using Classes… Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 30

3.4 Difference between classes and Id,s you can’t have more than one tag with the same ID value You can apply the same Class value to multiple document tags Classes or Id? use ID's for any elements that are simply used once on a page OR only use classes to style websites, but, when you have to use an element in JavaScript, use an identifier Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 31

Summary CSS basics CSS writing option CSS rules Id,s and Classes Basharat Mahm ood, Department of Computer Science, CIIT,Islamabad, Pakistan 32

Chapter 7, Beginning HTML, XHTML,CSS, and JavaScript, by Jon Duckett, Wiley Publishing; 2009, ISBN: Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. References