SlideShare a Scribd company logo
Concept of CSS
UNIT III
PART I
BY:SURBHI SAROHA
SYLLABUS
• Creating Style Sheet
• CSS Properties
• CSS Styling(Background , Text
Format , Controlling Fonts)
• Working with block elements and
objects
• Working with lists and Tables
SURBHI SAROHA
2
Creating Style Sheet
• <!DOCTYPE html>
• <html>
• <head>
• <style>
• body {
• background-color: lightblue;
• }
• h1 {
• color: white;
• text-align: center;
• }
SURBHI SAROHA
3
CSS Example
• p {
• font-family: verdana;
• font-size: 20px;
• }
• </style>
• </head>
• <body>
• <h1>My First CSS Example</h1>
• <p>This is a paragraph.</p>
• </body>
• </html>
SURBHI SAROHA
4
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 style sheets are stored in CSS files
SURBHI SAROHA
5
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.
• The style definitions are normally saved in external .css
files.
• 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!
SURBHI SAROHA
6
CSS Syntax
• A CSS rule-set consists of a selector and a
declaration block:
SURBHI SAROHA
7
Cont….
• 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.
• Multiple CSS declarations are separated with
semicolons, and declaration blocks are
surrounded by curly braces.
SURBHI SAROHA
8
In this example all <p> elements will be
center-aligned, with a red text color:
• <!DOCTYPE html>
• <html>
• <head>
• <style>
• p {
• color: red;
• text-align: center;
• }
• </style>
• </head>
• <body>
SURBHI SAROHA
9
Cont…
• <p>Hello World!</p>
• <p>These paragraphs are styled with CSS.</p>
• </body>
• </html>
SURBHI SAROHA
10
CSS Properties
• Font Properties
• Font Family
• Font Style
• Font Variant
• Font Weight
• Font Size
• Font
SURBHI SAROHA
11
Cont…
• Color and Background Properties
• Color
• Background Color
• Background Image
• Background Repeat
• Background Attachment
• Background Position
• Background
SURBHI SAROHA
12
Cont….
• Text Properties
• Word Spacing
• Letter Spacing
• Text Decoration
• Vertical Alignment
• Text Transformation
• Text Alignment
• Text Indentation
• Line Height
SURBHI SAROHA
13
CSS Styling(Background , Text Format ,
Controlling Fonts)
• Styling Fonts with CSS
• Choosing the right font and style is very crucial
for the readability of text on a page.
• CSS provide several properties for styling the
font of the text, including changing their face,
controlling their size and boldness, managing
variant, and so on.
• The font properties are: font-family, font-
style, font-weight, font-size, and font-variant.
SURBHI SAROHA
14
Font Family
• The font-family property is used to specify the font
to be used to render the text.
• This property can hold several comma-separated
font names as a fallback system, so that if the first
font is not available on the user's system, browser
tries to use the second one, and so on.
• Hence, list the font that you want first, then any
fonts that might fill in for the first if it is not
available.
• You should end the list with a generic font family
which are five —
• serif, sans-serif, monospace, cursive and fantasy.
SURBHI SAROHA
15
Example
• body { font-family: Arial, Helvetica, sans-serif; }
• <!DOCTYPE html>
• <html lang="en">
• <head>
• <meta charset="utf-8">
• <title>Setting font-family in CSS</title>
• <style>
• body {
• font-family: Arial, Helvetica, sans-serif;
• }
SURBHI SAROHA
16
Cont….
• </style>
• </head>
• <body>
• <h1>This is a heading</h1>
• <p>This is a paragraph.</p>
• </body>
• </html>
SURBHI SAROHA
17
Font Style
• The font-style property is used to set the font
face style for the text content of an element.
• The font style can be normal, italic or oblique.
The default value is normal.
SURBHI SAROHA
18
Example
• <!DOCTYPE html>
• <html lang="en">
• <head>
• <meta charset="utf-8">
• <title>Setting font-style in CSS</title>
• <style>
• p.normal {
• font-style: normal;
• }
• p.italic {
• font-style: italic;
• }
SURBHI SAROHA
19
Cont….
• p.oblique {
• font-style: oblique;
• }
• </style>
• </head>
• <body>
• <p class="normal">This is a normal paragraph.</p>
• <p class="italic">This is a paragraph with italic font
style.</p>
• <p class="oblique">This is a paragraph with oblique
font style.</p>
• </body>
• </html>
SURBHI SAROHA
20
Font size
• The font-size property is used to set the size of
font for the text content of an element.
• There are several ways to specify the font size
values e.g. with keywords, percentage, pixels,
ems, etc.
SURBHI SAROHA
21
Example
• <!DOCTYPE html>
• <html lang="en">
• <head>
• <meta charset="utf-8">
• <title>Defining Font Size Using Pixels</title>
• <style>
• h1 {
• font-size: 24px;
• }
• p {
• font-size: 14px;
• }
SURBHI SAROHA
22
Cont…
• </style>
• </head>
• <body>
• <h1>This is a heading</h1>
• <p>This is a paragraph.</p>
• </body>
• </html>
SURBHI SAROHA
23
Working with block elements and
objects
• block: This turns any styled element into a block,
after which further block-styling attributes may
be applied.
• Block-level elements take up the full width of
available space, including line space above and
below the element, similar to the way
paragraphs have space above and below them.
SURBHI SAROHA
24
Cont…
• The size and position of an element are often
impacted by its containing block. Most often,
the containing block is the content area of an
element's nearest block-level ancestor, but this is
not always the case.
• In this article, we examine the factors that
determine an element's containing block.
• When a user agent (such as your browser) lays
out a document, it generates a box for every
element.
SURBHI SAROHA
25
Cont….
• Each box is divided into four areas:
• Content area
• Padding area
• Border area
• Margin area
SURBHI SAROHA
26
SURBHI SAROHA
27
Working with lists and Tables
• You can set following properties of a table −
• The border-collapse specifies whether the
browser should control the appearance of the
adjacent borders that touch each other or whether
each cell should maintain its style.
• The border-spacing specifies the width that
should appear between table cells.
• The caption-side captions are presented in the
<caption> element. By default, these are rendered
above the table in the document. You use
the caption-side property to control the placement
of the table caption.
SURBHI SAROHA
28
CSS - Tables
• The empty-cells specifies whether the border
should be shown if a cell is empty.
• The table-layout allows browsers to speed up
layout of a table by using the first width
properties it comes across for the rest of a
column rather than having to load the whole
table before rendering it.
SURBHI SAROHA
29
The border-spacing Property
• <style type="text/css">
• /* If you provide one value */
• table.example {border-spacing:10px;}
• /* This is how you can provide two values */
• table.example {border-spacing:10px; 15px;}
• </style>
SURBHI SAROHA
30
The caption-side Property
• The caption-side property allows you to specify
where the content of a <caption> element
should be placed in relationship to the table.
• The table that follows lists the possible values.
• This property can have one of the four
values top, bottom, left or right. The following
example uses each value.
SURBHI SAROHA
31
The caption-side Property
• <html>
• <head>
• <style type = "text/css">
• caption.top {caption-side:top}
• caption.bottom {caption-side:bottom}
• caption.left {caption-side:left}
• caption.right {caption-side:right}
• </style>
• </head>
• <body>
•
SURBHI SAROHA
32
The caption-side Property
• <table style = "width:400px; border:1px solid black;">
• <caption class = "top"> This caption will appear at the
top </caption> <tr><td > Cell A</td></tr>
• <tr><td > Cell B</td></tr>
• </table> <br />
• <table style = "width:400px; border:1px solid black;">
• <caption class = "bottom"> This caption will appear at
the bottom </caption>
• <tr><td > Cell A</td></tr>
• <tr><td > Cell B</td>
• </tr>
• </table>
SURBHI SAROHA
33
The caption-side Property
• <br /> <table style = "width:400px; border:1px solid black;">
• <caption class = "left"> This caption will appear at the left
</caption>
• <tr><td > Cell A</td></tr>
• <tr><td > Cell B</td></tr>
• </table> <br /> <table style = "width:400px; border:1px
solid black;">
• <caption class = "right"> This caption will appear at the right
</caption>
• <tr><td > Cell A</td></tr>
• <tr><td > Cell B</td></tr>
• </table>
• </body>
• </html>
SURBHI SAROHA
34
SURBHI SAROHA
35
CSS - Lists
• We have the following five CSS properties, which can be
used to control lists −
• The list-style-type allows you to control the shape or
appearance of the marker.
• The list-style-position specifies whether a long point
that wraps to a second line should align with the first line
or start underneath the start of the marker.
• The list-style-image specifies an image for the marker
rather than a bullet point or number.
• The list-style serves as shorthand for the preceding
properties.
• The marker-offset specifies the distance between a
marker and the text in the list.
SURBHI SAROHA
36
Example
• <html>
• <head> </head>
• <body>
• <ul style = "list-style-type:circle;"> <li>Maths</li>
• <li>Social Science</li>
• <li>Physics</li>
• </ul> <ul style = "list-style-type:square;">
<li>Maths</li>
• <li>Social Science</li> <li>Physics</li>
• </ul> <ol style = "list-style-type:decimal;">
<li>Maths</li>
SURBHI SAROHA
37
Cont….
• <li>Social Science</li>
• <li>Physics</li>
• </ol> <ol style = "list-style-type:lower-alpha;">
<li>Maths</li>
• <li>Social Science</li>
• <li>Physics</li> </ol>
• <ol style = "list-style-type:lower-roman;">
<li>Maths</li>
• <li>Social Science</li>
• <li>Physics</li> </ol>
• </body>
• </html>
SURBHI SAROHA
38
SURBHI SAROHA
39
The list-style Property
• The list-style allows you to specify all the list
properties into a single expression. These
properties can appear in any order.
• Here is an example −
SURBHI SAROHA
40
Example
• <html>
• <head> </head>
• <body> <ul style = "list-style: inside square;">
<li>Maths</li>
• <li>Social Science</li>
• <li>Physics</li>
• </ul> <ol style = "list-style: outside upper-alpha;">
• <li>Maths</li>
• <li>Social Science</li>
• <li>Physics</li> </ol>
• </body>
• </html>
SURBHI SAROHA
41
SURBHI SAROHA
42
Thank you 
SURBHI SAROHA
43

More Related Content

What's hot (20)

PPSX
Javascript variables and datatypes
Varun C M
 
PPTX
HTML Forms
Nisa Soomro
 
PPT
introduction to web technology
vikram singh
 
PPTX
Php operators
Aashiq Kuchey
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PPTX
Css box-model
Webtech Learning
 
PPTX
Html forms
Er. Nawaraj Bhandari
 
PDF
Html forms
eShikshak
 
PDF
Basics of JavaScript
Bala Narayanan
 
PPTX
jQuery
Dileep Mishra
 
PPT
Java Script ppt
Priya Goyal
 
PPT
RichControl in Asp.net
Bhumivaghasiya
 
PPTX
HTML iframe
raman156413
 
PDF
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
PPT
PHP variables
Siddique Ibrahim
 
PPTX
Php
Shyam Khant
 
ODP
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
PDF
Bootstrap 5 basic
Jubair Ahmed Junjun
 
PPTX
Java script
Abhishek Kesharwani
 
Javascript variables and datatypes
Varun C M
 
HTML Forms
Nisa Soomro
 
introduction to web technology
vikram singh
 
Php operators
Aashiq Kuchey
 
PHP FUNCTIONS
Zeeshan Ahmed
 
Css box-model
Webtech Learning
 
Html forms
eShikshak
 
Basics of JavaScript
Bala Narayanan
 
Java Script ppt
Priya Goyal
 
RichControl in Asp.net
Bhumivaghasiya
 
HTML iframe
raman156413
 
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
PHP variables
Siddique Ibrahim
 
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
Bootstrap 5 basic
Jubair Ahmed Junjun
 
Java script
Abhishek Kesharwani
 

Similar to Concept of CSS unit3 (20)

PPTX
html-css
Dhirendra Chauhan
 
PPTX
CSS
DivyaKS12
 
PDF
Css from scratch
Ahmad Al-ammar
 
PPT
Cascading style sheet
VARSHAKUMARI49
 
PPTX
CSS_Day_Two (W3schools)
Rafi Haidari
 
PPTX
CSS Basics part One
M Ashraful Islam Jewel
 
PPTX
CSS tutorial chapter 1
jeweltutin
 
PDF
cascading stylesheet_cssppt-100604051600-phpapp02.pdf
hinalsomani93
 
PPTX
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
PPTX
Concept of CSS part 2
Dr. SURBHI SAROHA
 
PDF
Introduction to CSS3
Seble Nigussie
 
PPTX
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
PDF
Web Typography
Shawn Calvert
 
PDF
Unit 3 (it workshop).pptx
Dr.Lokesh Gagnani
 
PPTX
CSS.pptx
PushpaLatha551681
 
PDF
CSS notes
Rajendra Prasad
 
PPTX
HTML-CSS-QUARTER4 COMPUTER PROGRAMMING SSC
300179
 
PPTX
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
PDF
Css
actacademy
 
Css from scratch
Ahmad Al-ammar
 
Cascading style sheet
VARSHAKUMARI49
 
CSS_Day_Two (W3schools)
Rafi Haidari
 
CSS Basics part One
M Ashraful Islam Jewel
 
CSS tutorial chapter 1
jeweltutin
 
cascading stylesheet_cssppt-100604051600-phpapp02.pdf
hinalsomani93
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
Concept of CSS part 2
Dr. SURBHI SAROHA
 
Introduction to CSS3
Seble Nigussie
 
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
Web Typography
Shawn Calvert
 
Unit 3 (it workshop).pptx
Dr.Lokesh Gagnani
 
CSS notes
Rajendra Prasad
 
HTML-CSS-QUARTER4 COMPUTER PROGRAMMING SSC
300179
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
Ad

More from Dr. SURBHI SAROHA (20)

PPTX
Deep learning(UNIT 3) BY Ms SURBHI SAROHA
Dr. SURBHI SAROHA
 
PPTX
MOBILE COMPUTING UNIT 2 by surbhi saroha
Dr. SURBHI SAROHA
 
PPTX
Mobile Computing UNIT 1 by surbhi saroha
Dr. SURBHI SAROHA
 
PPTX
DEEP LEARNING (UNIT 2 ) by surbhi saroha
Dr. SURBHI SAROHA
 
PPTX
Introduction to Deep Leaning(UNIT 1).pptx
Dr. SURBHI SAROHA
 
PPTX
Cloud Computing (Infrastructure as a Service)UNIT 2
Dr. SURBHI SAROHA
 
PPTX
Management Information System(Unit 2).pptx
Dr. SURBHI SAROHA
 
PPTX
Searching in Data Structure(Linear search and Binary search)
Dr. SURBHI SAROHA
 
PPTX
Management Information System(UNIT 1).pptx
Dr. SURBHI SAROHA
 
PPTX
Introduction to Cloud Computing(UNIT 1).pptx
Dr. SURBHI SAROHA
 
PPTX
JAVA (UNIT 5)
Dr. SURBHI SAROHA
 
PPTX
DBMS (UNIT 5)
Dr. SURBHI SAROHA
 
PPTX
DBMS UNIT 4
Dr. SURBHI SAROHA
 
PPTX
JAVA(UNIT 4)
Dr. SURBHI SAROHA
 
PPTX
OOPs & C++(UNIT 5)
Dr. SURBHI SAROHA
 
PPTX
OOPS & C++(UNIT 4)
Dr. SURBHI SAROHA
 
PPTX
DBMS UNIT 3
Dr. SURBHI SAROHA
 
PPTX
JAVA (UNIT 3)
Dr. SURBHI SAROHA
 
PPTX
Keys in dbms(UNIT 2)
Dr. SURBHI SAROHA
 
PPTX
DBMS (UNIT 2)
Dr. SURBHI SAROHA
 
Deep learning(UNIT 3) BY Ms SURBHI SAROHA
Dr. SURBHI SAROHA
 
MOBILE COMPUTING UNIT 2 by surbhi saroha
Dr. SURBHI SAROHA
 
Mobile Computing UNIT 1 by surbhi saroha
Dr. SURBHI SAROHA
 
DEEP LEARNING (UNIT 2 ) by surbhi saroha
Dr. SURBHI SAROHA
 
Introduction to Deep Leaning(UNIT 1).pptx
Dr. SURBHI SAROHA
 
Cloud Computing (Infrastructure as a Service)UNIT 2
Dr. SURBHI SAROHA
 
Management Information System(Unit 2).pptx
Dr. SURBHI SAROHA
 
Searching in Data Structure(Linear search and Binary search)
Dr. SURBHI SAROHA
 
Management Information System(UNIT 1).pptx
Dr. SURBHI SAROHA
 
Introduction to Cloud Computing(UNIT 1).pptx
Dr. SURBHI SAROHA
 
JAVA (UNIT 5)
Dr. SURBHI SAROHA
 
DBMS (UNIT 5)
Dr. SURBHI SAROHA
 
DBMS UNIT 4
Dr. SURBHI SAROHA
 
JAVA(UNIT 4)
Dr. SURBHI SAROHA
 
OOPs & C++(UNIT 5)
Dr. SURBHI SAROHA
 
OOPS & C++(UNIT 4)
Dr. SURBHI SAROHA
 
DBMS UNIT 3
Dr. SURBHI SAROHA
 
JAVA (UNIT 3)
Dr. SURBHI SAROHA
 
Keys in dbms(UNIT 2)
Dr. SURBHI SAROHA
 
DBMS (UNIT 2)
Dr. SURBHI SAROHA
 
Ad

Recently uploaded (20)

PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
community health nursing question paper 2.pdf
Prince kumar
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 

Concept of CSS unit3

  • 1. Concept of CSS UNIT III PART I BY:SURBHI SAROHA
  • 2. SYLLABUS • Creating Style Sheet • CSS Properties • CSS Styling(Background , Text Format , Controlling Fonts) • Working with block elements and objects • Working with lists and Tables SURBHI SAROHA 2
  • 3. Creating Style Sheet • <!DOCTYPE html> • <html> • <head> • <style> • body { • background-color: lightblue; • } • h1 { • color: white; • text-align: center; • } SURBHI SAROHA 3
  • 4. CSS Example • p { • font-family: verdana; • font-size: 20px; • } • </style> • </head> • <body> • <h1>My First CSS Example</h1> • <p>This is a paragraph.</p> • </body> • </html> SURBHI SAROHA 4
  • 5. 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 style sheets are stored in CSS files SURBHI SAROHA 5
  • 6. 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. • The style definitions are normally saved in external .css files. • 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! SURBHI SAROHA 6
  • 7. CSS Syntax • A CSS rule-set consists of a selector and a declaration block: SURBHI SAROHA 7
  • 8. Cont…. • 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. • Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded by curly braces. SURBHI SAROHA 8
  • 9. In this example all <p> elements will be center-aligned, with a red text color: • <!DOCTYPE html> • <html> • <head> • <style> • p { • color: red; • text-align: center; • } • </style> • </head> • <body> SURBHI SAROHA 9
  • 10. Cont… • <p>Hello World!</p> • <p>These paragraphs are styled with CSS.</p> • </body> • </html> SURBHI SAROHA 10
  • 11. CSS Properties • Font Properties • Font Family • Font Style • Font Variant • Font Weight • Font Size • Font SURBHI SAROHA 11
  • 12. Cont… • Color and Background Properties • Color • Background Color • Background Image • Background Repeat • Background Attachment • Background Position • Background SURBHI SAROHA 12
  • 13. Cont…. • Text Properties • Word Spacing • Letter Spacing • Text Decoration • Vertical Alignment • Text Transformation • Text Alignment • Text Indentation • Line Height SURBHI SAROHA 13
  • 14. CSS Styling(Background , Text Format , Controlling Fonts) • Styling Fonts with CSS • Choosing the right font and style is very crucial for the readability of text on a page. • CSS provide several properties for styling the font of the text, including changing their face, controlling their size and boldness, managing variant, and so on. • The font properties are: font-family, font- style, font-weight, font-size, and font-variant. SURBHI SAROHA 14
  • 15. Font Family • The font-family property is used to specify the font to be used to render the text. • This property can hold several comma-separated font names as a fallback system, so that if the first font is not available on the user's system, browser tries to use the second one, and so on. • Hence, list the font that you want first, then any fonts that might fill in for the first if it is not available. • You should end the list with a generic font family which are five — • serif, sans-serif, monospace, cursive and fantasy. SURBHI SAROHA 15
  • 16. Example • body { font-family: Arial, Helvetica, sans-serif; } • <!DOCTYPE html> • <html lang="en"> • <head> • <meta charset="utf-8"> • <title>Setting font-family in CSS</title> • <style> • body { • font-family: Arial, Helvetica, sans-serif; • } SURBHI SAROHA 16
  • 17. Cont…. • </style> • </head> • <body> • <h1>This is a heading</h1> • <p>This is a paragraph.</p> • </body> • </html> SURBHI SAROHA 17
  • 18. Font Style • The font-style property is used to set the font face style for the text content of an element. • The font style can be normal, italic or oblique. The default value is normal. SURBHI SAROHA 18
  • 19. Example • <!DOCTYPE html> • <html lang="en"> • <head> • <meta charset="utf-8"> • <title>Setting font-style in CSS</title> • <style> • p.normal { • font-style: normal; • } • p.italic { • font-style: italic; • } SURBHI SAROHA 19
  • 20. Cont…. • p.oblique { • font-style: oblique; • } • </style> • </head> • <body> • <p class="normal">This is a normal paragraph.</p> • <p class="italic">This is a paragraph with italic font style.</p> • <p class="oblique">This is a paragraph with oblique font style.</p> • </body> • </html> SURBHI SAROHA 20
  • 21. Font size • The font-size property is used to set the size of font for the text content of an element. • There are several ways to specify the font size values e.g. with keywords, percentage, pixels, ems, etc. SURBHI SAROHA 21
  • 22. Example • <!DOCTYPE html> • <html lang="en"> • <head> • <meta charset="utf-8"> • <title>Defining Font Size Using Pixels</title> • <style> • h1 { • font-size: 24px; • } • p { • font-size: 14px; • } SURBHI SAROHA 22
  • 23. Cont… • </style> • </head> • <body> • <h1>This is a heading</h1> • <p>This is a paragraph.</p> • </body> • </html> SURBHI SAROHA 23
  • 24. Working with block elements and objects • block: This turns any styled element into a block, after which further block-styling attributes may be applied. • Block-level elements take up the full width of available space, including line space above and below the element, similar to the way paragraphs have space above and below them. SURBHI SAROHA 24
  • 25. Cont… • The size and position of an element are often impacted by its containing block. Most often, the containing block is the content area of an element's nearest block-level ancestor, but this is not always the case. • In this article, we examine the factors that determine an element's containing block. • When a user agent (such as your browser) lays out a document, it generates a box for every element. SURBHI SAROHA 25
  • 26. Cont…. • Each box is divided into four areas: • Content area • Padding area • Border area • Margin area SURBHI SAROHA 26
  • 28. Working with lists and Tables • You can set following properties of a table − • The border-collapse specifies whether the browser should control the appearance of the adjacent borders that touch each other or whether each cell should maintain its style. • The border-spacing specifies the width that should appear between table cells. • The caption-side captions are presented in the <caption> element. By default, these are rendered above the table in the document. You use the caption-side property to control the placement of the table caption. SURBHI SAROHA 28
  • 29. CSS - Tables • The empty-cells specifies whether the border should be shown if a cell is empty. • The table-layout allows browsers to speed up layout of a table by using the first width properties it comes across for the rest of a column rather than having to load the whole table before rendering it. SURBHI SAROHA 29
  • 30. The border-spacing Property • <style type="text/css"> • /* If you provide one value */ • table.example {border-spacing:10px;} • /* This is how you can provide two values */ • table.example {border-spacing:10px; 15px;} • </style> SURBHI SAROHA 30
  • 31. The caption-side Property • The caption-side property allows you to specify where the content of a <caption> element should be placed in relationship to the table. • The table that follows lists the possible values. • This property can have one of the four values top, bottom, left or right. The following example uses each value. SURBHI SAROHA 31
  • 32. The caption-side Property • <html> • <head> • <style type = "text/css"> • caption.top {caption-side:top} • caption.bottom {caption-side:bottom} • caption.left {caption-side:left} • caption.right {caption-side:right} • </style> • </head> • <body> • SURBHI SAROHA 32
  • 33. The caption-side Property • <table style = "width:400px; border:1px solid black;"> • <caption class = "top"> This caption will appear at the top </caption> <tr><td > Cell A</td></tr> • <tr><td > Cell B</td></tr> • </table> <br /> • <table style = "width:400px; border:1px solid black;"> • <caption class = "bottom"> This caption will appear at the bottom </caption> • <tr><td > Cell A</td></tr> • <tr><td > Cell B</td> • </tr> • </table> SURBHI SAROHA 33
  • 34. The caption-side Property • <br /> <table style = "width:400px; border:1px solid black;"> • <caption class = "left"> This caption will appear at the left </caption> • <tr><td > Cell A</td></tr> • <tr><td > Cell B</td></tr> • </table> <br /> <table style = "width:400px; border:1px solid black;"> • <caption class = "right"> This caption will appear at the right </caption> • <tr><td > Cell A</td></tr> • <tr><td > Cell B</td></tr> • </table> • </body> • </html> SURBHI SAROHA 34
  • 36. CSS - Lists • We have the following five CSS properties, which can be used to control lists − • The list-style-type allows you to control the shape or appearance of the marker. • The list-style-position specifies whether a long point that wraps to a second line should align with the first line or start underneath the start of the marker. • The list-style-image specifies an image for the marker rather than a bullet point or number. • The list-style serves as shorthand for the preceding properties. • The marker-offset specifies the distance between a marker and the text in the list. SURBHI SAROHA 36
  • 37. Example • <html> • <head> </head> • <body> • <ul style = "list-style-type:circle;"> <li>Maths</li> • <li>Social Science</li> • <li>Physics</li> • </ul> <ul style = "list-style-type:square;"> <li>Maths</li> • <li>Social Science</li> <li>Physics</li> • </ul> <ol style = "list-style-type:decimal;"> <li>Maths</li> SURBHI SAROHA 37
  • 38. Cont…. • <li>Social Science</li> • <li>Physics</li> • </ol> <ol style = "list-style-type:lower-alpha;"> <li>Maths</li> • <li>Social Science</li> • <li>Physics</li> </ol> • <ol style = "list-style-type:lower-roman;"> <li>Maths</li> • <li>Social Science</li> • <li>Physics</li> </ol> • </body> • </html> SURBHI SAROHA 38
  • 40. The list-style Property • The list-style allows you to specify all the list properties into a single expression. These properties can appear in any order. • Here is an example − SURBHI SAROHA 40
  • 41. Example • <html> • <head> </head> • <body> <ul style = "list-style: inside square;"> <li>Maths</li> • <li>Social Science</li> • <li>Physics</li> • </ul> <ol style = "list-style: outside upper-alpha;"> • <li>Maths</li> • <li>Social Science</li> • <li>Physics</li> </ol> • </body> • </html> SURBHI SAROHA 41
  • 43. Thank you  SURBHI SAROHA 43