SlideShare a Scribd company logo
CSSCascading Style Sheets
What is CSS?
O CSS stands for Cascading Style Sheets
O CSS describes how HTML elements are to be
displayed on screen or on a web page.
O CSS is a style language that defines layout of HTML
documents. For example, CSS covers fonts, colours,
margins, lines, height, width, background images and
many other things.
O CSS files can help define font, size, colour, spacing,
border and location of HTML information on a web
page, and can also be used to create a continuous look
throughout multiple pages of a website.
By Hansa(Hansika)
Halai
Why css?
O Saves Your Time
O Saves Your Visitors Time(less loading time)
O Gives You Design Flexibility
O Easier to maintain and update
O Multiple Device Compatibility
By Hansa(Hansika)
Halai
How it works?
O Syntax:
property : value;
O Ex:
color: red;
What is important to remember is that both
properties and values are case-sensitive in
CSS. The property and value in each pair is
separated by a colon (:).
By Hansa(Hansika)
Halai
O CSS declaration blocks:
• 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.
O Syntax:
Selector{property : value;
property : value;
}
The selector points to the HTML element you want to style.
By Hansa(Hansika)
Halai
OEx : p {
color: red;
text-align: center;
}
By Hansa(Hansika)
Halai
CSS Selectors
O CSS selectors are used to "find" (or select) HTML
elements based on their element name, id, class
and attribute.
O The element Selector
• The element selector selects elements based on
the element name.
Ex:
You can select all <p> elements on a page like the
example on next slide..
By Hansa(Hansika)
Halai
By Hansa(Hansika)
Halai
O The id Selector
• The id selector uses the id attribute of an HTML
element to select a specific element.
• The id of an element should be unique within a
page, so the id selector is used to select one
unique element!
• To select an element with a specific id, write a hash
(#) character, followed by the id of the element.
• The style rule in example (next slide) will be applied
to the HTML element with id="para1“ and also
different with id=“para2”.
By Hansa(Hansika)
Halai
Note: An id name cannot start with a number! By Hansa(Hansika)
Halai
O The class selector selects elements with a specific
class attribute.
O To select elements with a specific class, write a period
(.) character, followed by the name of the class.(P
sector in example)
O You can also specify that only specific HTML elements
should be affected by a class.(h1 sector in example)
O You will see both method’s example on next slide..
By Hansa(Hansika)
Halai
Note: A class name cannot start with a number! By Hansa(Hansika)
Halai
O Grouping Selectors
• If you have elements with the same style definitions.
• It will be better to group the selectors, to minimize the
code.
• To group selectors, separate each selector with a
comma.
Instead of write like this, you can write in
this sorter way
By Hansa(Hansika)
Halai
By Hansa(Hansika)
Halai
O 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:
O Ex:
By Hansa(Hansika)
Halai
How to insert CSS?
O There are three ways of inserting a style sheet:
• External style sheet
• Internal style sheet
• Inline style
1. External Style Sheet:
• With an external style sheet, you just need to create
separate css file where you manage entire look of your
website.
• Each page must include a reference to the external style
sheet file inside the <link> element. The <link> element
goes inside the <head> section. By Hansa(Hansika)
Halai
O 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.
O Ex: This is how test.css file look
like
Output
By Hansa(Hansika)
Halai
2. 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.
• The downside of using an internal stylesheet is that
changes to the internal stylesheet only effect the
page the code is inserted into.
By Hansa(Hansika)
Halai
By Hansa(Hansika)
Halai
3. 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.
• Ex:
By Hansa(Hansika)
Halai
Multiple Style Sheets
O If some properties have been defined for the same
selector (element) in different style sheets, the value
from the last read style sheet will be used.
O Ex:
• Assume that an external style sheet (mystyle.css)has the
following style for the <h1> element:
mystyle.css
h1{
color: navy;
}
By Hansa(Hansika)
Halai
By Hansa(Hansika)
Halai
Few examples:
By Hansa(Hansika)
Halai
By Hansa(Hansika)
Halai
What is CSS?

More Related Content

PPT
Css Ppt
PPT
CSS Basics
PPT
Css lecture notes
PPTX
HTML5 & CSS3
PPT
Advanced Cascading Style Sheets
PDF
Html table tags
PDF
Introduction to CSS3
Css Ppt
CSS Basics
Css lecture notes
HTML5 & CSS3
Advanced Cascading Style Sheets
Html table tags
Introduction to CSS3

What's hot (20)

PPTX
Html ppt
PPTX
Html links
PDF
Introduction to HTML5
PPTX
Php string function
PPTX
css.ppt
PDF
Html / CSS Presentation
PPTX
Complete Lecture on Css presentation
PPT
Introduction to java beans
PPTX
Css pseudo-classes
PDF
Basic Html Notes
PPTX
Ajax
PPTX
Css Display Property
PPT
PPT
Javascript
PPT
Developing an ASP.NET Web Application
PDF
Introduction to HTML and CSS
PDF
Intro to HTML and CSS basics
PPTX
Event In JavaScript
Html ppt
Html links
Introduction to HTML5
Php string function
css.ppt
Html / CSS Presentation
Complete Lecture on Css presentation
Introduction to java beans
Css pseudo-classes
Basic Html Notes
Ajax
Css Display Property
Javascript
Developing an ASP.NET Web Application
Introduction to HTML and CSS
Intro to HTML and CSS basics
Event In JavaScript
Ad

Similar to What is CSS? (20)

PPTX
chitra
PPTX
Cascading style sheet an introduction
PPTX
CSS_Day_ONE (W3schools)
PPTX
cascading style sheets- About cascading style sheets on the selectors
PPTX
Cascading style sheet, CSS Box model, Table in CSS
PPTX
Lecture-6.pptx
PPTX
Cascading Style Sheets for web browser.pptx
PPTX
CSS Basics (Cascading Style Sheet)
PPTX
UNIT 3WOP fgfufhbuiibpvihbvpihivbhibvipuuvbiuvboi
PPT
CSS Training in Bangalore
DOCX
CSS Tutorial For Basic Students Studying
PPTX
Cascading Styling Sheets(CSS) simple design language intended to transform th...
PDF
CSS.pdf
PPTX
PPTX
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
PPTX
INTRODUCTIONS OF CSS
PPTX
CSS (Cascading Style Sheet)
PPTX
CASCADING STYLE SHEETS (CSS).pptx
chitra
Cascading style sheet an introduction
CSS_Day_ONE (W3schools)
cascading style sheets- About cascading style sheets on the selectors
Cascading style sheet, CSS Box model, Table in CSS
Lecture-6.pptx
Cascading Style Sheets for web browser.pptx
CSS Basics (Cascading Style Sheet)
UNIT 3WOP fgfufhbuiibpvihbvpihivbhibvipuuvbiuvboi
CSS Training in Bangalore
CSS Tutorial For Basic Students Studying
Cascading Styling Sheets(CSS) simple design language intended to transform th...
CSS.pdf
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
INTRODUCTIONS OF CSS
CSS (Cascading Style Sheet)
CASCADING STYLE SHEETS (CSS).pptx
Ad

Recently uploaded (20)

PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Software Engineering BSC DS UNIT 1 .pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
O7-L3 Supply Chain Operations - ICLT Program
Software Engineering BSC DS UNIT 1 .pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Renaissance Architecture: A Journey from Faith to Humanism
Open folder Downloads.pdf yes yes ges yes
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Cardiovascular Pharmacology for pharmacy students.pptx
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
Module 3: Health Systems Tutorial Slides S2 2025
Open Quiz Monsoon Mind Game Prelims.pptx
The Final Stretch: How to Release a Game and Not Die in the Process.
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
NOI Hackathon - Summer Edition - GreenThumber.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

What is CSS?

  • 2. What is CSS? O CSS stands for Cascading Style Sheets O CSS describes how HTML elements are to be displayed on screen or on a web page. O CSS is a style language that defines layout of HTML documents. For example, CSS covers fonts, colours, margins, lines, height, width, background images and many other things. O CSS files can help define font, size, colour, spacing, border and location of HTML information on a web page, and can also be used to create a continuous look throughout multiple pages of a website. By Hansa(Hansika) Halai
  • 3. Why css? O Saves Your Time O Saves Your Visitors Time(less loading time) O Gives You Design Flexibility O Easier to maintain and update O Multiple Device Compatibility By Hansa(Hansika) Halai
  • 4. How it works? O Syntax: property : value; O Ex: color: red; What is important to remember is that both properties and values are case-sensitive in CSS. The property and value in each pair is separated by a colon (:). By Hansa(Hansika) Halai
  • 5. O CSS declaration blocks: • 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. O Syntax: Selector{property : value; property : value; } The selector points to the HTML element you want to style. By Hansa(Hansika) Halai
  • 6. OEx : p { color: red; text-align: center; } By Hansa(Hansika) Halai
  • 7. CSS Selectors O CSS selectors are used to "find" (or select) HTML elements based on their element name, id, class and attribute. O The element Selector • The element selector selects elements based on the element name. Ex: You can select all <p> elements on a page like the example on next slide.. By Hansa(Hansika) Halai
  • 9. O The id Selector • The id selector uses the id attribute of an HTML element to select a specific element. • The id of an element should be unique within a page, so the id selector is used to select one unique element! • To select an element with a specific id, write a hash (#) character, followed by the id of the element. • The style rule in example (next slide) will be applied to the HTML element with id="para1“ and also different with id=“para2”. By Hansa(Hansika) Halai
  • 10. Note: An id name cannot start with a number! By Hansa(Hansika) Halai
  • 11. O The class selector selects elements with a specific class attribute. O To select elements with a specific class, write a period (.) character, followed by the name of the class.(P sector in example) O You can also specify that only specific HTML elements should be affected by a class.(h1 sector in example) O You will see both method’s example on next slide.. By Hansa(Hansika) Halai
  • 12. Note: A class name cannot start with a number! By Hansa(Hansika) Halai
  • 13. O Grouping Selectors • If you have elements with the same style definitions. • It will be better to group the selectors, to minimize the code. • To group selectors, separate each selector with a comma. Instead of write like this, you can write in this sorter way By Hansa(Hansika) Halai
  • 15. O 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: O Ex: By Hansa(Hansika) Halai
  • 16. How to insert CSS? O There are three ways of inserting a style sheet: • External style sheet • Internal style sheet • Inline style 1. External Style Sheet: • With an external style sheet, you just need to create separate css file where you manage entire look of your website. • Each page must include a reference to the external style sheet file inside the <link> element. The <link> element goes inside the <head> section. By Hansa(Hansika) Halai
  • 17. O 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. O Ex: This is how test.css file look like Output By Hansa(Hansika) Halai
  • 18. 2. 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. • The downside of using an internal stylesheet is that changes to the internal stylesheet only effect the page the code is inserted into. By Hansa(Hansika) Halai
  • 20. 3. 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. • Ex: By Hansa(Hansika) Halai
  • 21. Multiple Style Sheets O If some properties have been defined for the same selector (element) in different style sheets, the value from the last read style sheet will be used. O Ex: • Assume that an external style sheet (mystyle.css)has the following style for the <h1> element: mystyle.css h1{ color: navy; } By Hansa(Hansika) Halai