SlideShare a Scribd company logo
What is CSS?
• CSS stands for Cascading Style Sheets
• CSS describes how HTML elements are to be
displayed on screen, paper, or in other media
• CSS saves a lot of work. It can control the
layout of multiple web pages all at once
• External stylesheets are stored in CSS files
Why Use CSS?
CSS is used to define styles for your web
pages, including the design, layout and
variations in display for different devices and
screen sizes.
CSS Solved a Big Problem
• HTML was NEVER intended to contain tags for formatting a web
page!
• HTML was created to describe the content of a web page, like:
• <h1>This is a heading</h1>
• <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 websites, 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.
• CSS removed the style formatting from the HTML page!
CSS Saves a Lot of Work!
• The style definitions are normally saved in
external .css files.
• With an external stylesheet file, you can
change the look of an entire website by
changing just one file!
CSS Syntax
• A CSS rule-set consists of a selector and a declaration
block:
• The selector points to the HTML element you want to
style.
• The declaration block contains one or more
declarations separated by semicolons.
• Each declaration includes a CSS property name and a
value, separated by a colon.
• A CSS declaration always ends with a semicolon, and
declaration blocks are surrounded by curly braces.
CSS Selectors
• CSS selectors are used to "find" (or select)
HTML elements based on their element name,
tag,id, class, attribute, and more.
The element Selector
• The element selector selects elements based on
the element name.
• You can select all <p> elements on a page like this
(in this case, all <p> elements will be center-
aligned, with a red text color):
Example
p {
text-align: center;
color: red;
}
Selector
The id Selector
The class Selector
The class selector selects elements with a specific class
attribute.
• You can also specify that only specific HTML elements
should be affected by a class.
• In the example below, only <p> elements with
class="center" will be center-aligned:
• Example
• p.center {
text-align: center;
color: red;
}
More than one class
HTML elements can also refer to more than one
class.
the <p> element will be styled according to
class="center" and to class="large":
Example
<p class="center large">This paragraph refers to
two classes.</p>
Note: A class name cannot start with a number!
Grouping Selectors
• If you have elements with the same style definitions, like this:
• h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p {
text-align: center;
color: red;
}
• It will be better to group the selectors, to minimize the code.
• To group selectors, separate each selector with a comma.
• In the example below we have grouped the selectors from the code above:
Example
h1, h2, p {
text-align: center;
color: red;
}
CSS Comments
• Comments are used to explain the code, and
may help when you edit the source code at a
later date.
• Comments are ignored by browsers.
• A CSS comment starts with /* and ends with
*/. Comments can also span multiple lines:
CSS How To...
Three Ways to Insert CSS
There are three ways of inserting a style
sheet:
External style sheet
Internal style sheet
Inline style
External Style Sheet
With an external style sheet, you can change the look of an
entire website by changing just one file!
Each page must include a reference to the external style sheet
file inside the <link> element. The <link> element goes inside
the <head> 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. The
style sheet file must be saved with a .css extension.
Example
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20 px;
}
Note: Do not add a space between the property value
and the unit (such as margin-left: 20 px;). The correct
way is: margin-left: 20px;
Internal Style Sheet
An internal style sheet may be used if one single
page has a unique style.
Internal styles are defined within the <style>
element, inside the <head> section of an HTML
page:
Inline Styles
An inline style may be used to apply a unique style
for a single element.
To use inline styles, add the style attribute to the
relevant element. The style attribute can contain
any CSS property.
**Tip: An inline style loses many of the advantages
of a style sheet (by mixing content with
presentation). Use this method sparingly
CSS Colors
• Colors in CSS are most often specified by:
• a valid color name - like "red"
• an RGB value - like "rgb(255, 0, 0)"
• a HEX value - like "#ff0000“
• Follow exam[les
CSS Backgrounds
CSS background properties:
• background-color
• background-image
• background-repeat
• background-attachment
• background-position
Background Color
body {
background-color: lightblue;
}
Background Image
body {
background-image: url("paper.gif");
}
Background Image - Repeat Horizontally or
Vertically
• Please try to understand the example:
• Please be attentive.
• Background Image - Set position and no-
repeat
• Ex::
• We want to change the position of the image,
so that it does not disturb the text too much.
Background Property
• Background Image - Fixed position
• Background - Shorthand property
When using the shorthand property the order of
the property values is:
• background-color
• background-image
• background-repeat
• background-attachment
• background-position
Text Color
body {
color: blue;
}
h1 {
color: green;
}
****DO YOURSELF
Note: For W3C compliant CSS: If you define the
color property, you must also define the
background-color.
Text Alignment
• The text-align property is used to set the horizontal
alignment of a text.
• A text can be left or right aligned, centered, or justified.
h1 {
text-align: center;
}
h2 {
text-align: left;
}
h3 {
text-align: right; ///// ** Do yourself please
}
Text Decoration
• The text-decoration property is used to set or
remove decorations from text.
• The value text-decoration: none; is often used
to remove underlines from links:
Example
a {
text-decoration: none;
}
Text Decoration Example
• The other text-decoration values are used to decorate text:
Example
• h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
Text Transformation
• The text-transform property is used to specify
uppercase and lowercase letters in a text.
• ////Try yourself
Text Indentation
• The text-indent property is used to specify the
indentation of the first line of a text:
Example
p {
text-indent: 50px;
}
Letter Spacing
• The letter-spacing property is used to specify
the space between the characters in a text.
• Check the EXAMPLE
Line Height
• The line-height property is used to specify the
space between lines:
• Check example::
Text Direction
• The direction property is used to change the
text direction of an element:
• Example: --------------
Word Spacing
The word-spacing property is used to specify
the space between the words in a text.
The example demonstrates how to increase or
decrease the space between words:
Text Shadow
• The text-shadow property adds shadow to
text.
• Check The example
CSS Lists
HTML Lists and CSS List Properties
• In HTML, there are two main types of lists:
• unordered lists (<ul>) - the list items are marked with
bullets
• ordered lists (<ol>) - the list items are marked with
numbers or letters
• The CSS list properties allow you to:
• Set different list item markers for ordered lists
• Set different list item markers for unordered lists
• Set an image as the list item marker
• Add background colors to lists and list items
Different List Item Markers
• The list-style-type property specifies the type
of list item marker.
• Example
An Image as The List Item Marker
• The list-style-image property specifies an
image as the list item marker:
• Example: 
Position The List Item Markers
• The list-style-position property specifies
whether the list-item markers should appear
inside or outside the content flow:
• Ex 
List - Shorthand property
• When using the shorthand property, the order of the
property values are:
• list-style-type (if a list-style-image is specified, the
value of this property will be displayed if the image for
some reason cannot be displayed)
• list-style-position (specifies whether the list-item
markers should appear inside or outside the content
flow)
• list-style-image (specifies an image as the list item
marker)
• If one of the property values above are missing, the
default value for the missing property will be inserted,
if any.
CSS tutorial chapter 1

More Related Content

What's hot (20)

Le Wagon - UI and Design Crash Course
Le Wagon - UI and Design Crash CourseLe Wagon - UI and Design Crash Course
Le Wagon - UI and Design Crash Course
Boris Paillard
 
CSS
CSSCSS
CSS
DivyaKS12
 
Css
CssCss
Css
Hemant Saini
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
joilrahat
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Evolution Network
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
David Lindkvist
 
Html styles
Html stylesHtml styles
Html styles
Micah Fuentes
 
CSS Font & Text style
CSS Font & Text style CSS Font & Text style
CSS Font & Text style
Yaowaluck Promdee
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Folasade Adedeji
 
Html and css
Html and cssHtml and css
Html and css
Sukrit Gupta
 
2. html attributes
2. html attributes2. html attributes
2. html attributes
Muhammad Toqeer
 
Html formatting
Html formattingHtml formatting
Html formatting
Webtech Learning
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
Rachel Andrew
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
fantasticdigitaltools
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
Mario Hernandez
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
Tushar Joshi
 
Le Wagon - UI components design
Le Wagon - UI components designLe Wagon - UI components design
Le Wagon - UI components design
Boris Paillard
 

Similar to CSS tutorial chapter 1 (20)

CSS notes
CSS notesCSS notes
CSS notes
Rajendra Prasad
 
Css introduction
Css  introductionCss  introduction
Css introduction
vishnu murthy
 
Css
CssCss
Css
Kamal Acharya
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
css3.0.( Cascading Style Sheets ) pptx
css3.0.( Cascading  Style  Sheets ) pptxcss3.0.( Cascading  Style  Sheets ) pptx
css3.0.( Cascading Style Sheets ) pptx
neelkamal72809
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 
CSS
CSSCSS
CSS
venkatachalam84
 
Unit 3 (it workshop).pptx
Unit 3 (it workshop).pptxUnit 3 (it workshop).pptx
Unit 3 (it workshop).pptx
Dr.Lokesh Gagnani
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
Css
CssCss
Css
Yudha Arif Budiman
 
CSS
CSSCSS
CSS
People Strategists
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
Meenakshi Paul
 
Unit 2 WT-CSS.pptx web technology project
Unit 2 WT-CSS.pptx web technology projectUnit 2 WT-CSS.pptx web technology project
Unit 2 WT-CSS.pptx web technology project
abhiramhatwar
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3
Binu Paul
 
Cascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSSCascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptxCSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
IorlahaSamuel1
 
Css from scratch
Css from scratchCss from scratch
Css from scratch
Ahmad Al-ammar
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptxChapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
Css
CssCss
Css
NIRMAL FELIX
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
css3.0.( Cascading Style Sheets ) pptx
css3.0.( Cascading  Style  Sheets ) pptxcss3.0.( Cascading  Style  Sheets ) pptx
css3.0.( Cascading Style Sheets ) pptx
neelkamal72809
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
Unit 2 WT-CSS.pptx web technology project
Unit 2 WT-CSS.pptx web technology projectUnit 2 WT-CSS.pptx web technology project
Unit 2 WT-CSS.pptx web technology project
abhiramhatwar
 
Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3Cordova training - Day 2 Introduction to CSS 3
Cordova training - Day 2 Introduction to CSS 3
Binu Paul
 
Cascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSSCascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptxCSS – CASCADING STYLE SHEET - MY_PPT.pptx
CSS – CASCADING STYLE SHEET - MY_PPT.pptx
IorlahaSamuel1
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptxChapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 

Recently uploaded (20)

How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18
Celine George
 
How to Manage Allow Ship Later for Sold Product in odoo Point of Sale
How to Manage Allow Ship Later for Sold Product in odoo Point of SaleHow to Manage Allow Ship Later for Sold Product in odoo Point of Sale
How to Manage Allow Ship Later for Sold Product in odoo Point of Sale
Celine George
 
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
 
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Rajdeep Bavaliya
 
he Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Successhe Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Success
TechSoup
 
Salinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plantSalinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plant
aliabatool11
 
Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)
NileshKumbhar21
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-21-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-21-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-21-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-21-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdfUnit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
ChatanBawankar
 
Protest - Student Revision Booklet For VCE English
Protest - Student Revision Booklet For VCE EnglishProtest - Student Revision Booklet For VCE English
Protest - Student Revision Booklet For VCE English
jpinnuck
 
How to create Record rules in odoo 18 - Odoo Slides
How to create Record rules in odoo 18 - Odoo  SlidesHow to create Record rules in odoo 18 - Odoo  Slides
How to create Record rules in odoo 18 - Odoo Slides
Celine George
 
Taxonomy and Systematics: Classification and Diversity of Insects.pptx
Taxonomy and Systematics: Classification and Diversity of Insects.pptxTaxonomy and Systematics: Classification and Diversity of Insects.pptx
Taxonomy and Systematics: Classification and Diversity of Insects.pptx
Arshad Shaikh
 
EDI as Scientific Problem, Professor Nira Chamberlain OBE
EDI as Scientific Problem, Professor Nira Chamberlain OBEEDI as Scientific Problem, Professor Nira Chamberlain OBE
EDI as Scientific Problem, Professor Nira Chamberlain OBE
Association for Project Management
 
TechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdf
TechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdfTechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdf
TechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdf
TechSoup
 
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
ChatanBawankar
 
The Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptxThe Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptx
Arshad Shaikh
 
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
 
Electronics Engineering Assignment Help Guide – Expert Support for Students
Electronics Engineering Assignment Help Guide – Expert Support for StudentsElectronics Engineering Assignment Help Guide – Expert Support for Students
Electronics Engineering Assignment Help Guide – Expert Support for Students
online college homework help
 
Policies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptxPolicies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptx
mansk2
 
Drug Metabolism advanced medicinal chemistry.pptx
Drug Metabolism advanced medicinal chemistry.pptxDrug Metabolism advanced medicinal chemistry.pptx
Drug Metabolism advanced medicinal chemistry.pptx
pharmaworld
 
How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18
Celine George
 
How to Manage Allow Ship Later for Sold Product in odoo Point of Sale
How to Manage Allow Ship Later for Sold Product in odoo Point of SaleHow to Manage Allow Ship Later for Sold Product in odoo Point of Sale
How to Manage Allow Ship Later for Sold Product in odoo Point of Sale
Celine George
 
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
 
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Paper 110A | Shadows and Light: Exploring Expressionism in ‘The Cabinet of Dr...
Rajdeep Bavaliya
 
he Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Successhe Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Success
TechSoup
 
Salinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plantSalinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plant
aliabatool11
 
Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)
NileshKumbhar21
 
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdfUnit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
ChatanBawankar
 
Protest - Student Revision Booklet For VCE English
Protest - Student Revision Booklet For VCE EnglishProtest - Student Revision Booklet For VCE English
Protest - Student Revision Booklet For VCE English
jpinnuck
 
How to create Record rules in odoo 18 - Odoo Slides
How to create Record rules in odoo 18 - Odoo  SlidesHow to create Record rules in odoo 18 - Odoo  Slides
How to create Record rules in odoo 18 - Odoo Slides
Celine George
 
Taxonomy and Systematics: Classification and Diversity of Insects.pptx
Taxonomy and Systematics: Classification and Diversity of Insects.pptxTaxonomy and Systematics: Classification and Diversity of Insects.pptx
Taxonomy and Systematics: Classification and Diversity of Insects.pptx
Arshad Shaikh
 
TechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdf
TechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdfTechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdf
TechSoup Introduction to Generative AI and Copilot - 2025.05.22.pdf
TechSoup
 
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
ChatanBawankar
 
The Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptxThe Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptx
Arshad Shaikh
 
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
 
Electronics Engineering Assignment Help Guide – Expert Support for Students
Electronics Engineering Assignment Help Guide – Expert Support for StudentsElectronics Engineering Assignment Help Guide – Expert Support for Students
Electronics Engineering Assignment Help Guide – Expert Support for Students
online college homework help
 
Policies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptxPolicies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptx
mansk2
 
Drug Metabolism advanced medicinal chemistry.pptx
Drug Metabolism advanced medicinal chemistry.pptxDrug Metabolism advanced medicinal chemistry.pptx
Drug Metabolism advanced medicinal chemistry.pptx
pharmaworld
 

CSS tutorial chapter 1

  • 1. What is CSS? • CSS stands for Cascading Style Sheets • CSS describes how HTML elements are to be displayed on screen, paper, or in other media • CSS saves a lot of work. It can control the layout of multiple web pages all at once • External stylesheets are stored in CSS files
  • 2. Why Use CSS? CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.
  • 3. CSS Solved a Big Problem • HTML was NEVER intended to contain tags for formatting a web page! • HTML was created to describe the content of a web page, like: • <h1>This is a heading</h1> • <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 websites, 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. • CSS removed the style formatting from the HTML page!
  • 4. CSS Saves a Lot of Work! • The style definitions are normally saved in external .css files. • With an external stylesheet file, you can change the look of an entire website by changing just one file!
  • 5. CSS Syntax • A CSS rule-set consists of a selector and a declaration block: • The selector points to the HTML element you want to style. • The declaration block contains one or more declarations separated by semicolons. • Each declaration includes a CSS property name and a value, separated by a colon. • A CSS declaration always ends with a semicolon, and declaration blocks are surrounded by curly braces.
  • 6. CSS Selectors • CSS selectors are used to "find" (or select) HTML elements based on their element name, tag,id, class, attribute, and more.
  • 7. The element Selector • The element selector selects elements based on the element name. • You can select all <p> elements on a page like this (in this case, all <p> elements will be center- aligned, with a red text color): Example p { text-align: center; color: red; }
  • 8. Selector The id Selector The class Selector The class selector selects elements with a specific class attribute. • You can also specify that only specific HTML elements should be affected by a class. • In the example below, only <p> elements with class="center" will be center-aligned: • Example • p.center { text-align: center; color: red; }
  • 9. More than one class HTML elements can also refer to more than one class. the <p> element will be styled according to class="center" and to class="large": Example <p class="center large">This paragraph refers to two classes.</p> Note: A class name cannot start with a number!
  • 10. Grouping Selectors • If you have elements with the same style definitions, like this: • h1 { text-align: center; color: red; } h2 { text-align: center; color: red; } p { text-align: center; color: red; } • It will be better to group the selectors, to minimize the code. • To group selectors, separate each selector with a comma. • In the example below we have grouped the selectors from the code above: Example h1, h2, p { text-align: center; color: red; }
  • 11. CSS Comments • Comments are used to explain the code, and may help when you edit the source code at a later date. • Comments are ignored by browsers. • A CSS comment starts with /* and ends with */. Comments can also span multiple lines:
  • 12. CSS How To... Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style sheet Inline style
  • 13. External Style Sheet With an external style sheet, you can change the look of an entire website by changing just one file! Each page must include a reference to the external style sheet file inside the <link> element. The <link> element goes inside the <head> 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. The style sheet file must be saved with a .css extension.
  • 14. Example body { background-color: lightblue; } h1 { color: navy; margin-left: 20 px; } Note: Do not add a space between the property value and the unit (such as margin-left: 20 px;). The correct way is: margin-left: 20px;
  • 15. Internal Style Sheet An internal style sheet may be used if one single page has a unique style. Internal styles are defined within the <style> element, inside the <head> section of an HTML page:
  • 16. Inline Styles An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property. **Tip: An inline style loses many of the advantages of a style sheet (by mixing content with presentation). Use this method sparingly
  • 17. CSS Colors • Colors in CSS are most often specified by: • a valid color name - like "red" • an RGB value - like "rgb(255, 0, 0)" • a HEX value - like "#ff0000“ • Follow exam[les
  • 18. CSS Backgrounds CSS background properties: • background-color • background-image • background-repeat • background-attachment • background-position
  • 19. Background Color body { background-color: lightblue; } Background Image body { background-image: url("paper.gif"); }
  • 20. Background Image - Repeat Horizontally or Vertically • Please try to understand the example: • Please be attentive. • Background Image - Set position and no- repeat • Ex:: • We want to change the position of the image, so that it does not disturb the text too much.
  • 21. Background Property • Background Image - Fixed position • Background - Shorthand property When using the shorthand property the order of the property values is: • background-color • background-image • background-repeat • background-attachment • background-position
  • 22. Text Color body { color: blue; } h1 { color: green; } ****DO YOURSELF Note: For W3C compliant CSS: If you define the color property, you must also define the background-color.
  • 23. Text Alignment • The text-align property is used to set the horizontal alignment of a text. • A text can be left or right aligned, centered, or justified. h1 { text-align: center; } h2 { text-align: left; } h3 { text-align: right; ///// ** Do yourself please }
  • 24. Text Decoration • The text-decoration property is used to set or remove decorations from text. • The value text-decoration: none; is often used to remove underlines from links: Example a { text-decoration: none; }
  • 25. Text Decoration Example • The other text-decoration values are used to decorate text: Example • h1 { text-decoration: overline; } h2 { text-decoration: line-through; } h3 { text-decoration: underline; }
  • 26. Text Transformation • The text-transform property is used to specify uppercase and lowercase letters in a text. • ////Try yourself
  • 27. Text Indentation • The text-indent property is used to specify the indentation of the first line of a text: Example p { text-indent: 50px; }
  • 28. Letter Spacing • The letter-spacing property is used to specify the space between the characters in a text. • Check the EXAMPLE
  • 29. Line Height • The line-height property is used to specify the space between lines: • Check example::
  • 30. Text Direction • The direction property is used to change the text direction of an element: • Example: --------------
  • 31. Word Spacing The word-spacing property is used to specify the space between the words in a text. The example demonstrates how to increase or decrease the space between words:
  • 32. Text Shadow • The text-shadow property adds shadow to text. • Check The example
  • 33. CSS Lists HTML Lists and CSS List Properties • In HTML, there are two main types of lists: • unordered lists (<ul>) - the list items are marked with bullets • ordered lists (<ol>) - the list items are marked with numbers or letters • The CSS list properties allow you to: • Set different list item markers for ordered lists • Set different list item markers for unordered lists • Set an image as the list item marker • Add background colors to lists and list items
  • 34. Different List Item Markers • The list-style-type property specifies the type of list item marker. • Example
  • 35. An Image as The List Item Marker • The list-style-image property specifies an image as the list item marker: • Example: 
  • 36. Position The List Item Markers • The list-style-position property specifies whether the list-item markers should appear inside or outside the content flow: • Ex 
  • 37. List - Shorthand property • When using the shorthand property, the order of the property values are: • list-style-type (if a list-style-image is specified, the value of this property will be displayed if the image for some reason cannot be displayed) • list-style-position (specifies whether the list-item markers should appear inside or outside the content flow) • list-style-image (specifies an image as the list item marker) • If one of the property values above are missing, the default value for the missing property will be inserted, if any.