SlideShare a Scribd company logo
CSS
(CASCADING STYLE SHEETS)
1
WHAT IS CSS?
 Styles were added to HTML 4.0 to solve a problem
 HTML is used to structure content where as CSS is
used for formatting structured content.
 Unlike HTML, CSS doesn’t create anything.
 Instead it decorates, aligns and positions (etc) elements
in HTML.
 In a nut shell, CSS takes the normal HTML output &
adds a few rules to how it is actually displayed.
2
“CSS stands for Cascading Style Sheets”
“CSS is a style language that defines layout of HTML
documents.”
“Styles define how to display HTML elements”
STYLES SOLVED A BIG PROBLEM
 HTML was never intended to contain tags for formatting
a document.
 HTML was intended to define the content of a
document, like:
o <h1>This is a heading</h1>
o <p>This is a paragraph.</p>
 When tags like <font>, and color attributes were added
to the HTML 3.2 specification, it started a nightmare for
web developers. Development of large web sites, where
fonts and color information were added to every single
page, became a long and expensive process.
 To solve this problem, the World Wide Web Consortium
(W3C) created CSS.
 In HTML 4.0, all formatting could be removed from the
HTML document, and stored in a separate CSS file.
 All browsers support CSS today. 3
CSS SAVES A LOT OF WORK!
 Cascading Style Sheets are now the standard
way to define the presentation of your HTML pages.
They are much more efficient than using HTML on
every page to define the look of your site.
 A collection of style is commonly referred to as style
sheets.
 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!
4
CSS RULE
5
CSS RULE:
1. Selector this is the HTML tag that you want to style.
2. Property this is the attribute you adjust, control or
modify.
3. Value it is the style you apply to that property
selector
{ property : value;
property : value;
property : value; }
EXAMPLE:
1. h1 this is the HTML element that you want to
style.
2. color this is the attribute you adjust, control or
modify.
3. blue it is the style you apply to that property
7
h1 { color : blue;}
 Each selector can have multiple properties.
 Each property within the selector can have
independent values.
 The property & value are separated with a
colon & contained within curly brackets.
 Multiple properties are separate by a semi-
colon.
 Multiple values within a property are
separated by commas.
 Value in CSS doesn’t require quotation
marks except if the value has multiple
words.
8
HOW TO ADD CSS TO WEB PAGES?
9
HOW TO ADD CSS IN WEBPAGES:
There are three ways of inserting a
style sheet:
External
style sheet
Internal
style sheet
Inline style 10
ADDING CSS TO WEB PAGES:
1. It can be inserted within the header of a web page 
Internal style sheet
2. It can be inserted within the body of a web page
(usually in certain sections or individual elements)
Inline style sheet
3. It can be inserted within a separate web page 
External style sheet
1.INTERNAL STYLE SHEET
<head>
<style type=“text/css”>
h1 { color : blue;}
</style>
</head>
•The <STYLE> element is used in HEAD section to indicate style
information for the entire document.
•type It declares the type of data which is being linked to the
document. In case of CSS, the only allowed value is text/css.
2.INLINE STYLE SHEETS
 The value of style attribute is any combination of
style declarations.
 Also note that there aren’t any curly braces used
here, but the colon/semicolon rule still applies.
<element style=“…styles…”>
<p style="color: blue; font-family: Arial;
">
3.EXTERNAL STYLE SHEETS
<link rel=“stylesheet” type=“text/css” href=“” >
The <LINK> is a special HEAD element which indicates a
relationship between the current document & some other object. It
is mostly used to link style sheets.
rel It describes the relation of the linked file to the document itself. There
are 2 possible values:
1. stylesheet used to control the way the current document is
rendered.
2. alternate stylesheet used to control the way the current
document is rendered, but will not be used by default if a
"rel='stylesheet'" stylesheet is present and successfully loaded.
type It declares the type of data which is being linked to the document. In
case of CSS, the only allowed value is text/css.
href It is the URL of the external style sheet. Either relative or absolute
URLs may be needed. This attribute is required.
15
DOCUMENT TREE
html
head
Title
Body
h1 p
em
Example1. html
When you nest one element inside another, the nested element
will inherit the properties assigned to the containing element.
Unless you modify the inner element values independently.
COMMENTS IN CSS
/* comment goes here */
A CSS comment begins with
"/*", and ends with "*/", like this:
GROUPING SELECTORS
 In style sheets there are often elements with the
same style.
 To minimize the code, you can group selectors.
 To group selectors, separate them with comma.
h1{color:green;}
h2{color:green;}
p{color:green;}
h1,h2,p {color:green;}
View Example
CONTEXTUAL SELECTORS
 Contextual selectors define styles that are only applied
when certain tags are nested within other tags.
 This allows to use a tag & not have it adopt the CSS
attribute each time it is used.
 The selectors are separated by a space.
p i strong {color: red}
View Example
CLASS SELECTOR
o What would you do if you want some of the
paragraphs to appear bold while other ones do
not?
o Use a class selector!
o Class selectors allow you to associate a class
with a particular subset or class of elements.
GET INTO ACTION!
CLASS SELECTOR
 To create a class selector, use a period (.) followed
by the name you want for the class.
 This allows you to set a particular style for any
HTML elements with the same class.
.col {color:red;}
<p class=“col">
This is an example of multiple
classes.
</p>
GET INTO ACTION!
DIFFERENT INSTANCES OF A CLASS
SELECTOR
p.col {color:red;}
i.col{color:blue;}
• To create a class that can only apply to particular
elements, you need to specify that element in
selector.
• You can create generic selectors that can apply to
every HTML element.
MULTIPLE CLASSES
.applylarge
{
font-size:20px;
}
.applyred
{
color:#FF0000;
}
<p
class="applylarge
applyred">
This is an example
of multiple classes.
</p>
DEFINING CLASS IN CSS STYLE IN HTML <BODY>
ID SELECTOR
 The id selector is used to specify a style for a single,
unique element.
 It is defined by using a # symbol.
GET INTO ACTION!
#red{color:red;}
<h1 id="red"> ID selectors </h1>
CLASS VS ID
 The style is used in various places through out the document.
 The style is very general.
Use class if:
• The style is only used once ever in the document.
• The style is specific to a certain area of the
document.
Use ID if:

More Related Content

What's hot (20)

Web Design Assignment 1
Web Design Assignment 1 Web Design Assignment 1
Web Design Assignment 1
beretta21
 
CSS notes
CSS notesCSS notes
CSS notes
Rajendra Prasad
 
HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!
Syahmi RH
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
css.ppt
css.pptcss.ppt
css.ppt
bhasula
 
Css notes
Css notesCss notes
Css notes
Computer Hardware & Trouble shooting
 
CSS ppt
CSS pptCSS ppt
CSS ppt
Sanmuga Nathan
 
Css
CssCss
Css
Mukesh Tekwani
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
KushagraChadha1
 
Span and Div tags in HTML
Span and Div tags in HTMLSpan and Div tags in HTML
Span and Div tags in HTML
Biswadip Goswami
 
Html (1)
Html (1)Html (1)
Html (1)
smitha273566
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
Sanjeev Kumar
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
tutorialsruby
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
Santhiya Grace
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
Michael Jhon
 
Html training slide
Html training slideHtml training slide
Html training slide
villupuramtraining
 

Viewers also liked (16)

Css
CssCss
Css
Balakumaran Arunachalam
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Paul Dionysius
 
Cashcading stylesheets
Cashcading stylesheetsCashcading stylesheets
Cashcading stylesheets
reddivarihareesh
 
Cascading style sheets (css)
Cascading style sheets (css)Cascading style sheets (css)
Cascading style sheets (css)
veasnarin
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Marc Steel
 
Html Css
Html CssHtml Css
Html Css
pumas26
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By Mukesh
Mukesh Kumar
 
CSS
CSSCSS
CSS
Vladimir Zhidal
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
iFour Institute - Sustainable Learning
 
Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
Reshmi Rajan
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
Rachel Andrew
 
CSS-Cascading Style Sheets - Introduction
CSS-Cascading Style Sheets - IntroductionCSS-Cascading Style Sheets - Introduction
CSS-Cascading Style Sheets - Introduction
Mukesh Tekwani
 
CSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box ModelCSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box Model
jamiecavanaugh
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
Sun Technlogies
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
SlideShare
 

Similar to Introduction to CSS (20)

Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Erin M. Kidwell
 
Css introduction
Css introductionCss introduction
Css introduction
Sridhar P
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationLecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType Classification
ZahouAmel1
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
Singsys Pte Ltd
 
This is css which compiled by alex that is impo
This is css which compiled by alex that is impoThis is css which compiled by alex that is impo
This is css which compiled by alex that is impo
AlebelAyalneh
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Mukesh Tekwani
 
Css Introduction
Css IntroductionCss Introduction
Css Introduction
SathyaseelanK1
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptxLecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptx
GmachImen
 
Introduction of css
Introduction of cssIntroduction of css
Introduction of css
Dinesh Kumar
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Joseph Gabriel
 
Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
vishal choudhary
 
Css - Tutorial
Css - TutorialCss - Tutorial
Css - Tutorial
adelaticleanu
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
Sohail Christoper
 
lecture CSS 1-2_2022_2023.pptx
lecture CSS 1-2_2022_2023.pptxlecture CSS 1-2_2022_2023.pptx
lecture CSS 1-2_2022_2023.pptx
zheerhimdad
 
CSS Foundations, pt 1
CSS Foundations, pt 1CSS Foundations, pt 1
CSS Foundations, pt 1
Shawn Calvert
 
chitra
chitrachitra
chitra
sweet chitra
 
Css
CssCss
Css
Abhishek Kesharwani
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
Abhishek Kesharwani
 
Csstutorial
CsstutorialCsstutorial
Csstutorial
Ankit Rana
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
Abhishek Kesharwani
 

Recently uploaded (20)

The Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdfThe Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdf
Mirza Gazanfar Ali Baig
 
Education Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond IncomeEducation Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond Income
EducationNC
 
What are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS MarketingWhat are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS Marketing
Celine George
 
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
Melanie Wood
 
Odoo 18 Point of Sale PWA - Odoo Slides
Odoo 18 Point of Sale PWA  - Odoo  SlidesOdoo 18 Point of Sale PWA  - Odoo  Slides
Odoo 18 Point of Sale PWA - Odoo Slides
Celine George
 
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptxQUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
Sourav Kr Podder
 
How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18
How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18
How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18
Celine George
 
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academyGeographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Sandeep Swamy
 
Primary Bash in Richmond 2025 - Literacy.pdf
Primary Bash in Richmond 2025 - Literacy.pdfPrimary Bash in Richmond 2025 - Literacy.pdf
Primary Bash in Richmond 2025 - Literacy.pdf
Faye Brownlie
 
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ..."Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
Arshad Shaikh
 
Optical and non optical devices used in low vision
Optical and non optical devices used in low visionOptical and non optical devices used in low vision
Optical and non optical devices used in low vision
Aligarh Muslim University, Aligarh, Uttar Pradesh, India
 
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
Jenny408767
 
Flower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdfFlower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdf
kushallamichhame
 
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
Unit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdfUnit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdf
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
ChatanBawankar
 
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANASTUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
Kweku Zurek
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
siemaillard
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-25-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-25-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-25-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-25-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Philosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum DesigningPhilosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum Designing
Ankit Choudhary
 
SAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDS
SAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDSSAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDS
SAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDS
Anand Kumar
 
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
Julián Jesús Pérez Fernández
 
The Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdfThe Splitting of the Moon (Shaqq al-Qamar).pdf
The Splitting of the Moon (Shaqq al-Qamar).pdf
Mirza Gazanfar Ali Baig
 
Education Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond IncomeEducation Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond Income
EducationNC
 
What are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS MarketingWhat are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS Marketing
Celine George
 
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
Melanie Wood
 
Odoo 18 Point of Sale PWA - Odoo Slides
Odoo 18 Point of Sale PWA  - Odoo  SlidesOdoo 18 Point of Sale PWA  - Odoo  Slides
Odoo 18 Point of Sale PWA - Odoo Slides
Celine George
 
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptxQUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
Sourav Kr Podder
 
How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18
How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18
How to Add a Custom Menu, List view and FIlters in the Customer Portal Odoo 18
Celine George
 
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academyGeographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Geographical-Diversity-of-India.pptx/7th class /new ncert /samyans academy
Sandeep Swamy
 
Primary Bash in Richmond 2025 - Literacy.pdf
Primary Bash in Richmond 2025 - Literacy.pdfPrimary Bash in Richmond 2025 - Literacy.pdf
Primary Bash in Richmond 2025 - Literacy.pdf
Faye Brownlie
 
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ..."Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
Arshad Shaikh
 
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
Jenny408767
 
Flower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdfFlower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdf
kushallamichhame
 
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
Unit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdfUnit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdf
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
ChatanBawankar
 
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANASTUDENT LOAN TRUST FUND DEFAULTERS GHANA
STUDENT LOAN TRUST FUND DEFAULTERS GHANA
Kweku Zurek
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
siemaillard
 
Philosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum DesigningPhilosophical Basis of Curriculum Designing
Philosophical Basis of Curriculum Designing
Ankit Choudhary
 
SAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDS
SAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDSSAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDS
SAMARTH QUIZ 2024-25_ PRELIMINARY ROUNDS
Anand Kumar
 

Introduction to CSS

  • 2. WHAT IS CSS?  Styles were added to HTML 4.0 to solve a problem  HTML is used to structure content where as CSS is used for formatting structured content.  Unlike HTML, CSS doesn’t create anything.  Instead it decorates, aligns and positions (etc) elements in HTML.  In a nut shell, CSS takes the normal HTML output & adds a few rules to how it is actually displayed. 2 “CSS stands for Cascading Style Sheets” “CSS is a style language that defines layout of HTML documents.” “Styles define how to display HTML elements”
  • 3. STYLES SOLVED A BIG PROBLEM  HTML was never intended to contain tags for formatting a document.  HTML was intended to define the content of a document, like: o <h1>This is a heading</h1> o <p>This is a paragraph.</p>  When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large web sites, where fonts and color information were added to every single page, became a long and expensive process.  To solve this problem, the World Wide Web Consortium (W3C) created CSS.  In HTML 4.0, all formatting could be removed from the HTML document, and stored in a separate CSS file.  All browsers support CSS today. 3
  • 4. CSS SAVES A LOT OF WORK!  Cascading Style Sheets are now the standard way to define the presentation of your HTML pages. They are much more efficient than using HTML on every page to define the look of your site.  A collection of style is commonly referred to as style sheets.  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! 4
  • 6. CSS RULE: 1. Selector this is the HTML tag that you want to style. 2. Property this is the attribute you adjust, control or modify. 3. Value it is the style you apply to that property selector { property : value; property : value; property : value; }
  • 7. EXAMPLE: 1. h1 this is the HTML element that you want to style. 2. color this is the attribute you adjust, control or modify. 3. blue it is the style you apply to that property 7 h1 { color : blue;}
  • 8.  Each selector can have multiple properties.  Each property within the selector can have independent values.  The property & value are separated with a colon & contained within curly brackets.  Multiple properties are separate by a semi- colon.  Multiple values within a property are separated by commas.  Value in CSS doesn’t require quotation marks except if the value has multiple words. 8
  • 9. HOW TO ADD CSS TO WEB PAGES? 9
  • 10. HOW TO ADD CSS IN WEBPAGES: There are three ways of inserting a style sheet: External style sheet Internal style sheet Inline style 10
  • 11. ADDING CSS TO WEB PAGES: 1. It can be inserted within the header of a web page  Internal style sheet 2. It can be inserted within the body of a web page (usually in certain sections or individual elements) Inline style sheet 3. It can be inserted within a separate web page  External style sheet
  • 12. 1.INTERNAL STYLE SHEET <head> <style type=“text/css”> h1 { color : blue;} </style> </head> •The <STYLE> element is used in HEAD section to indicate style information for the entire document. •type It declares the type of data which is being linked to the document. In case of CSS, the only allowed value is text/css.
  • 13. 2.INLINE STYLE SHEETS  The value of style attribute is any combination of style declarations.  Also note that there aren’t any curly braces used here, but the colon/semicolon rule still applies. <element style=“…styles…”> <p style="color: blue; font-family: Arial; ">
  • 14. 3.EXTERNAL STYLE SHEETS <link rel=“stylesheet” type=“text/css” href=“” >
  • 15. The <LINK> is a special HEAD element which indicates a relationship between the current document & some other object. It is mostly used to link style sheets. rel It describes the relation of the linked file to the document itself. There are 2 possible values: 1. stylesheet used to control the way the current document is rendered. 2. alternate stylesheet used to control the way the current document is rendered, but will not be used by default if a "rel='stylesheet'" stylesheet is present and successfully loaded. type It declares the type of data which is being linked to the document. In case of CSS, the only allowed value is text/css. href It is the URL of the external style sheet. Either relative or absolute URLs may be needed. This attribute is required. 15
  • 16. DOCUMENT TREE html head Title Body h1 p em Example1. html When you nest one element inside another, the nested element will inherit the properties assigned to the containing element. Unless you modify the inner element values independently.
  • 17. COMMENTS IN CSS /* comment goes here */ A CSS comment begins with "/*", and ends with "*/", like this:
  • 18. GROUPING SELECTORS  In style sheets there are often elements with the same style.  To minimize the code, you can group selectors.  To group selectors, separate them with comma. h1{color:green;} h2{color:green;} p{color:green;} h1,h2,p {color:green;} View Example
  • 19. CONTEXTUAL SELECTORS  Contextual selectors define styles that are only applied when certain tags are nested within other tags.  This allows to use a tag & not have it adopt the CSS attribute each time it is used.  The selectors are separated by a space. p i strong {color: red} View Example
  • 20. CLASS SELECTOR o What would you do if you want some of the paragraphs to appear bold while other ones do not? o Use a class selector! o Class selectors allow you to associate a class with a particular subset or class of elements. GET INTO ACTION!
  • 21. CLASS SELECTOR  To create a class selector, use a period (.) followed by the name you want for the class.  This allows you to set a particular style for any HTML elements with the same class. .col {color:red;} <p class=“col"> This is an example of multiple classes. </p> GET INTO ACTION!
  • 22. DIFFERENT INSTANCES OF A CLASS SELECTOR p.col {color:red;} i.col{color:blue;} • To create a class that can only apply to particular elements, you need to specify that element in selector. • You can create generic selectors that can apply to every HTML element.
  • 23. MULTIPLE CLASSES .applylarge { font-size:20px; } .applyred { color:#FF0000; } <p class="applylarge applyred"> This is an example of multiple classes. </p> DEFINING CLASS IN CSS STYLE IN HTML <BODY>
  • 24. ID SELECTOR  The id selector is used to specify a style for a single, unique element.  It is defined by using a # symbol. GET INTO ACTION! #red{color:red;} <h1 id="red"> ID selectors </h1>
  • 25. CLASS VS ID  The style is used in various places through out the document.  The style is very general. Use class if: • The style is only used once ever in the document. • The style is specific to a certain area of the document. Use ID if: