SlideShare a Scribd company logo
CSS: Cascading Style Sheet
Prepared By:
Dr.J.Shiny Duela
Assistant Professor
Dept. of CSE
Jerusalem College of Engineering
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
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 are used to "find" (or select) HTML elements
based on their element name, id, class, attribute, and more.
• The element Selector
p {
text-align: center;
color: red;
}
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.
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
The class Selector
• The class selector selects elements with a specific class
attribute.
• To select elements with a specific class, write a period (.)
character, followed by the name of the class.
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">Red and center-aligned heading</h1>
<p class="center">Red and center-aligned paragraph.</p>
</body>
</html>
Grouping Selectors
h1, h2, p {
text-align: center;
color: red;
}
Border Color
• <!DOCTYPE html>
• <html>
• <body>
• <h1 style="border: 2px solid Tomato;">Hello World</h1>
• <h1 style="border: 2px solid DodgerBlue;">Hello World</h1>
• <h1 style="border: 2px solid Violet;">Hello World</h1>
• </body>
• </html>
Css
Border Style
• The border-style property specifies what kind of border to display.
• The following values are allowed:
• dotted - Defines a dotted border
• dashed - Defines a dashed border
• solid - Defines a solid border
• double - Defines a double border
• groove - Defines a 3D grooved border. The effect depends on the border-color value
• ridge - Defines a 3D ridged border. The effect depends on the border-color value
• inset - Defines a 3D inset border. The effect depends on the border-color value
• outset - Defines a 3D outset border. The effect depends on the border-color value
• none - Defines no border
• hidden - Defines a hidden border
• p.dotted {border-style: dotted;}
p.dashed {border-style: dashed;}
p.solid {border-style: solid;}
p.double {border-style: double;}
p.groove {border-style: groove;}
p.ridge {border-style: ridge;}
p.inset {border-style: inset;}
p.outset {border-style: outset;}
p.none {border-style: none;}
p.hidden {border-style: hidden;}
p.mix {border-style: dotted dashed solid double;}
Css
CSS Margins
• Margin - Individual Sides
• CSS has properties for specifying the margin for each side of an element:
• margin-top
• margin-right
• margin-bottom
• margin-left
• All the margin properties can have the following values:
• auto - the browser calculates the margin
• length - specifies a margin in px, pt, cm, etc.
• % - specifies a margin in % of the width of the containing element
• inherit - specifies that the margin should be inherited from the parent element
p {
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
}
SHORTHAND PROPERTY:
p {
margin: 25px 50px 75px 100px;
}
CSS Padding
• The CSS padding properties are used to generate space around an element's
content, inside of any defined borders.
• With CSS, you have full control over the padding. There are properties for
setting the padding for each side of an element (top, right, bottom, and left).
• padding-top
• padding-right
• padding-bottom
• padding-left
• length - specifies a padding in px, pt, cm, etc.
• % - specifies a padding in % of the width of the containing element
• inherit - specifies that the padding should be inherited from the parent element
• div {
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}
The CSS Box Model
• All HTML elements can be considered as boxes.
• In CSS, the term "box model" is used when talking about design
and layout.
• The CSS box model is essentially a box that wraps around
every HTML element.
• It consists of: margins, borders, padding, and the actual
content.
• The image below illustrates the box model:
• Content - The content of the box, where text and images appear
• Padding - Clears an area around the content. The padding is transparent
• Border - A border that goes around the padding and content
• Margin - Clears an area outside the border. The margin is transparent
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: lightgrey;
width: 300px;
border: 25px solid green;
padding: 25px;
margin: 25px;
}
</style></head>
<body>
<h2>Demonstrating the Box Model</h2>
<p>The CSS box model is essentially a box that wraps around every HTML element. It consists of: borders, padding,
margins, and the actual content.</p>
<div>This text is the actual content of the box. We have added a 25px padding, 25px margin and a 25px green border.
</div>
</body>
</html>
THANK U

More Related Content

PPTX
PPTX
Css ppt
PPTX
Introduction to HTML and CSS
PPTX
Css intro
PPTX
Web topic 15 1 basic css layout
PPT
Introduction to Cascading Style Sheets (CSS)
PPTX
Web Development - Lecture 6
PPTX
Css ppt
Introduction to HTML and CSS
Css intro
Web topic 15 1 basic css layout
Introduction to Cascading Style Sheets (CSS)
Web Development - Lecture 6

What's hot (20)

PPTX
Complete Lecture on Css presentation
PPT
Introduction to CSS
PPT
Basic css
PDF
Unit 2 (it workshop)
PPTX
Beginners css tutorial for web designers
PDF
Unit 3 (it workshop).pptx
PPTX
CSS Basic Introduction, Rules, And Tips
PPT
Cascading Style Sheets(CSS)
PPT
Cascading Style Sheets (CSS) help
PPT
CSS for basic learner
PPTX
CSS Basics part One
PPTX
CSS tutorial chapter 3
PPTX
CSS introduction
PPTX
CSS tutorial chapter 2
PDF
CSS: a rapidly changing world
PPTX
Responsive web design with html5 and css3
PPT
CSS Introduction
PPTX
Languages for web(HTML,CSS,JS)
Complete Lecture on Css presentation
Introduction to CSS
Basic css
Unit 2 (it workshop)
Beginners css tutorial for web designers
Unit 3 (it workshop).pptx
CSS Basic Introduction, Rules, And Tips
Cascading Style Sheets(CSS)
Cascading Style Sheets (CSS) help
CSS for basic learner
CSS Basics part One
CSS tutorial chapter 3
CSS introduction
CSS tutorial chapter 2
CSS: a rapidly changing world
Responsive web design with html5 and css3
CSS Introduction
Languages for web(HTML,CSS,JS)
Ad

Similar to Css (20)

PPTX
Casecading Style Sheets for Hyper Text Transfer Protocol.pptx
PPTX
CSS Topic wise Short notes ppt by Navya.E
PPTX
Unit - 3 CSS(Cascading Style Sheet).pptx
PPTX
Unit-3-CSS-BWT.pptx
PPTX
CSS document। .pptx
PPTX
PPTX
Unit 2 WT-CSS.pptx web technology project
PPTX
Html Styles-CSS
PPTX
WEB TECHNOLOGY Unit-2.pptx
PPTX
UNIT 3WOP fgfufhbuiibpvihbvpihivbhibvipuuvbiuvboi
PPTX
Introduction to Wed System And Technologies (1).pptx
PPTX
WT CSS
PPTX
BITM3730Week4.pptx
PDF
Intro to html, css & sass
PPTX
Cascading style sheets
PPTX
Cascading Style Sheets for web browser.pptx
PPTX
Cascading style sheets
PPT
CSS-part-1.ppt
PPTX
CSS tutorial chapter 1
Casecading Style Sheets for Hyper Text Transfer Protocol.pptx
CSS Topic wise Short notes ppt by Navya.E
Unit - 3 CSS(Cascading Style Sheet).pptx
Unit-3-CSS-BWT.pptx
CSS document। .pptx
Unit 2 WT-CSS.pptx web technology project
Html Styles-CSS
WEB TECHNOLOGY Unit-2.pptx
UNIT 3WOP fgfufhbuiibpvihbvpihivbhibvipuuvbiuvboi
Introduction to Wed System And Technologies (1).pptx
WT CSS
BITM3730Week4.pptx
Intro to html, css & sass
Cascading style sheets
Cascading Style Sheets for web browser.pptx
Cascading style sheets
CSS-part-1.ppt
CSS tutorial chapter 1
Ad

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
Classroom Observation Tools for Teachers
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Pre independence Education in Inndia.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Pharma ospi slides which help in ospi learning
Classroom Observation Tools for Teachers
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pre independence Education in Inndia.pdf
01-Introduction-to-Information-Management.pdf
human mycosis Human fungal infections are called human mycosis..pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Complications of Minimal Access Surgery at WLH
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Basic Mud Logging Guide for educational purpose
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Css

  • 1. CSS: Cascading Style Sheet Prepared By: Dr.J.Shiny Duela Assistant Professor Dept. of CSE Jerusalem College of Engineering
  • 2. 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
  • 3. 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.
  • 4. • CSS selectors are used to "find" (or select) HTML elements based on their element name, id, class, attribute, and more. • The element Selector p { text-align: center; color: red; }
  • 5. 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.
  • 6. <!DOCTYPE html> <html> <head> <style> #para1 { text-align: center; color: red; } </style> </head> <body> <p id="para1">Hello World!</p> <p>This paragraph is not affected by the style.</p> </body> </html>
  • 7. The class Selector • The class selector selects elements with a specific class attribute. • To select elements with a specific class, write a period (.) character, followed by the name of the class.
  • 8. <!DOCTYPE html> <html> <head> <style> .center { text-align: center; color: red; } </style> </head> <body> <h1 class="center">Red and center-aligned heading</h1> <p class="center">Red and center-aligned paragraph.</p> </body> </html>
  • 9. Grouping Selectors h1, h2, p { text-align: center; color: red; }
  • 10. Border Color • <!DOCTYPE html> • <html> • <body> • <h1 style="border: 2px solid Tomato;">Hello World</h1> • <h1 style="border: 2px solid DodgerBlue;">Hello World</h1> • <h1 style="border: 2px solid Violet;">Hello World</h1> • </body> • </html>
  • 12. Border Style • The border-style property specifies what kind of border to display. • The following values are allowed: • dotted - Defines a dotted border • dashed - Defines a dashed border • solid - Defines a solid border • double - Defines a double border • groove - Defines a 3D grooved border. The effect depends on the border-color value • ridge - Defines a 3D ridged border. The effect depends on the border-color value • inset - Defines a 3D inset border. The effect depends on the border-color value • outset - Defines a 3D outset border. The effect depends on the border-color value • none - Defines no border • hidden - Defines a hidden border
  • 13. • p.dotted {border-style: dotted;} p.dashed {border-style: dashed;} p.solid {border-style: solid;} p.double {border-style: double;} p.groove {border-style: groove;} p.ridge {border-style: ridge;} p.inset {border-style: inset;} p.outset {border-style: outset;} p.none {border-style: none;} p.hidden {border-style: hidden;} p.mix {border-style: dotted dashed solid double;}
  • 15. CSS Margins • Margin - Individual Sides • CSS has properties for specifying the margin for each side of an element: • margin-top • margin-right • margin-bottom • margin-left • All the margin properties can have the following values: • auto - the browser calculates the margin • length - specifies a margin in px, pt, cm, etc. • % - specifies a margin in % of the width of the containing element • inherit - specifies that the margin should be inherited from the parent element
  • 16. p { margin-top: 100px; margin-bottom: 100px; margin-right: 150px; margin-left: 80px; } SHORTHAND PROPERTY: p { margin: 25px 50px 75px 100px; }
  • 17. CSS Padding • The CSS padding properties are used to generate space around an element's content, inside of any defined borders. • With CSS, you have full control over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left). • padding-top • padding-right • padding-bottom • padding-left • length - specifies a padding in px, pt, cm, etc. • % - specifies a padding in % of the width of the containing element • inherit - specifies that the padding should be inherited from the parent element • div { padding-top: 50px; padding-right: 30px; padding-bottom: 50px; padding-left: 80px; }
  • 18. The CSS Box Model • All HTML elements can be considered as boxes. • In CSS, the term "box model" is used when talking about design and layout. • The CSS box model is essentially a box that wraps around every HTML element. • It consists of: margins, borders, padding, and the actual content. • The image below illustrates the box model:
  • 19. • Content - The content of the box, where text and images appear • Padding - Clears an area around the content. The padding is transparent • Border - A border that goes around the padding and content • Margin - Clears an area outside the border. The margin is transparent
  • 20. <!DOCTYPE html> <html> <head> <style> div { background-color: lightgrey; width: 300px; border: 25px solid green; padding: 25px; margin: 25px; } </style></head> <body> <h2>Demonstrating the Box Model</h2> <p>The CSS box model is essentially a box that wraps around every HTML element. It consists of: borders, padding, margins, and the actual content.</p> <div>This text is the actual content of the box. We have added a 25px padding, 25px margin and a 25px green border. </div> </body> </html>