SlideShare a Scribd company logo
Cascading Style Sheets
(CSS)
Prepared by
Divya K.S
Contents
• Introduction
• Internal style sheet
• External style sheet
• Controlling Text
• Text Formatting
• Selectors
• Box Model
• Backgrounds
• Tables
• Lists
Introduction to CSS
• What is meant by CSS?
CSS stands for Cascading Style Sheets.
CSS describes how HTML elements are to be displayed on screen, on
paper, or in other media.
CSS saves a lot of work. It can control the layout of multiple Web pages
all at once
What is a cascading style sheet?
Cascading Style Sheets (CSS) is a simple
mechanism for adding style (e.g., fonts, colors,
spacing) to Web documents.
CSS Syntax
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.
GROUPING SELECTORS
THREE WAYS TO INSERT CSS
There are three ways of inserting a style sheet:
• External style sheet
• Internal style sheet
• Inline style
Internal Style sheet
First we will explore the internal method. This way you are simply placing the
CSS code within the <head></head> tags of each (X)HTML file you want to style with
the CSS. The format for this is shown in the example below:
<head>
<title><title>
<style type=”text/css”>
CSS Content Goes Here
</style>
</head>
<body>
With this method each (X)HTML file
contains the CSS code needed to style
the page. Meaning that any changes you
want to make to one page, will have to
be made to all. This method can be
good if you need to style only one page,
or if you want different pages to have
varying styles.
External Style sheet
Next we will explore the external method. An external CSS file
can be created with any text or HTML editor such as “Notepad” or
“Dreamweaver”. A CSS file contains no (X)HTML, only CSS. You
simply save it with the .css file extension. You can link to the file
externally by placing one of the following links in the head section
of every (X)HTML file you want to style with the CSS file.
<link rel=”stylesheet” type=”text/css” href=“Path To
stylesheet.css” />
Or you can also use the @import method as shown below
<style type=”text/css”>@import url(Path To stylesheet.css)</style>
External Style sheet (contd..)
By using an external style sheet, all of your (X)HTML files link to
one CSS file in order to style the pages. This means, that if you need to
alter the design of all your pages, you only need to edit one .css file to
make global changes to your entire website.
• Here are a few reasons this is better.
• Easier Maintenance
• Reduced File Size
• Reduced Bandwidth
• Improved Flexibility
CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The selector is normally the HTML element you want to style.
Each declaration consists of a property and a value.
The property is the style attribute you want to change. Each property has a value.
CSS declarations always ends with a semicolon, and declaration groups are
surrounded by curly brackets:
p {color:red;text-align:center;}
CSS STYLINGBackground Color
The background-color property specifies the background color of an
element.
The background color of a page is defined in the body selector:
Example
body {background-color:#b0c4de;}
The background color can be specified by:
* name - a color name, like "red"
* RGB - an RGB value, like "rgb(255,0,0)"
* Hex - a hex value, like "#ff0000"
Background image
The background-image property specifies an image to use as the
background of an element.
By default, the image is repeated so it covers the entire element.
The background image for a page can be set like this:
Example
Body {background-image:url('paper.Gif');}
Below is an example of a bad combination of text and background
image.
Example
body {background-image:url('bgdesert.jpg');}
Background Image - Repeat Horizontally or Vertically
By default, the background-image property repeats an image
both horizontally and vertically.
Some images should be repeated only horizontally or vertically,
or they will look strange:
Example
body
{
background-image:url('gradient2.png');
}
Background Image - Set position and no-repeat
Remark When using a background image, use an image that does not
disturb the text.
Showing the image only once is specified by the background-repeat
property:
Example
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
}
Background - Shorthand property
As you can see from the examples above, there are many
properties to consider when dealing with backgrounds.
To shorten the code, it is also possible to specify all the
properties in one single property. This is called a shorthand
property.
The shorthand property for background is simply
"background":
Example
body {background:#ffffff url('img_tree.png') no-repeat right
top;}
Text Color
The color property is used to set the color of the text. The color can be specified
by:
* name - a color name, like "red"
* RGB - an RGB value, like "rgb(255,0,0)"
* Hex - a hex value, like "#ff0000"
The default color for a page is defined in the body selector.
Example
body {color:blue;}
h1 {color:#00ff00;}
h2 {color:rgb(255,0,0);}
Text Alignment
The text-align property is used to set the horizontal alignment of a text.
Text can be centered, or aligned to the left or right, or justified. When
text-align is set to "justify", each line is stretched so that every line has
equal width, and the left and right margins are straight (like in
magazines and newspapers).
Example
h1 {text-align:center;}
h2 {text-align:right;}
h3 {text-align:justify;}
Text Decoration
The text-decoration property is used to set or remove
decorations from text. The text-decoration property is
mostly used to remove underlines from links for design
purposes:
Example a {text-decoration:none;}
It can also be used to decorate text:
Example : h1 {text-decoration:overline;}
h3 {text-decoration:underline;}
h4 {text-decoration:blink;}
Text Transformation
The text-transform property is used to specify uppercase and
lowercase letters in a text. It can be used to turn everything into
uppercase or lowercase letters, or capitalize the first letter of each
word.
Example p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}
CSS Font Families
In CSS, there are two types of font family names:
* generic family - a group of font families with a similar look (like "Serif" or
"Monospace")
* font family - a specific font family (like "Times New Roman" or "Arial")
Font Family
The font family of a text is set with the font-family property. The font-family
property should hold several font names as a "fallback" system. If the browser
does not support the first font, it tries the next font. Start with the font you want,
and end with a generic family, to let the browser pick a similar font in the generic
family, if no other fonts are available.
Note: If the name of a font family is more than one word, it must be in quotation
marks, like font-family: "Times New Roman".
More than one font family is specified in a comma-separated list:
Example : p{font-family:"Times New Roman", Times, serif;}
Font Style
The font-style property is mostly used to specify italic text.
This property has three values:
* normal - The text is shown normally
* italic - The text is shown in italics
Example : p.normal {font-style:normal;}
p.italic {font-style:italic;}
Font Size
The font-size property sets the size of the text. Being able
to manage the text size is important in web design.
However, you should not use font size adjustments to
make paragraphs look like headings, or headings look like
paragraphs.
Always use the proper HTML tags, like <h1> - <h6> for
headings and <p> for paragraphs.
The font-size value can be an absolute, or relative size.
Set Font Size With Pixels
Setting the text size with pixels, gives you full control over the text size:
Example : h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:14px;}
Set Font Size With Em
To avoid the resizing problem with Internet Explorer, many developers use Em
instead of pixels.
The Em size unit is recommended by the W3C. 1 Em is equal to the current font
size. The default text size in browsers is 16px. So, the default size of 1em is 16px.
The size can be calculated from pixels to Em using this formula: pixels/16=Em
Example : h1 {font-size:2.5em;} /* 40px/16=2.5em */
h2 {font-size:1.875em;} /* 30px/16=1.875em */
p {font-size:0.875em;} /* 14px/16=0.875em */
CSS Selectors
• Three types of CSS Selectors
• Element
• Class
• ID
CSS Element Selector
• A CSS declaration always ends with a semicolon, and
declaration groups are surrounded by curly brackets:
• p {color:red;text-align:center;}
• To make the CSS more readable, you can put one
declaration on each line, like this:
• p { color:red; text-align:center; }
CSS Comments
• Comments are used to explain your code, and may help you
when you edit the source code at a later date. Comments are
ignored by browsers.
• A CSS comment begins with "/*", and ends with "*/", like this:
• /*This is a comment*/ p { text-align:center; /*This is another
comment*/ color:black;}
The id and class Selectors
• In addition to setting a style for a HTML element, CSS
allows you to specify your own selectors called "id" and
"class".
• id is used when we have to apply CSS property to one
attribute only.
• class is used when we have to use CSS property in many
locations within the same page or different.
CSS Syntax
#id {css declarations;}
EX. #firstname { backgroundcolor: yellow;}
The id Selector
• The id selector is used to specify a style for a single, unique element.
• The id selector uses the id attribute of the HTML element, and is defined with
a "#".
• Example
• Imagine within the body element of our html page, we have the following
paragraph element
• <p id=”welcome”>Welcome to the wonderful world of HTML</p>
• We can then create a CSS rule with the id selector:
• #welcome { text-align:center; color:red; }
The class Selector
• The class selector is used to specify a style for a group of
elements. Unlike the id selector, the class selector is most
often used on several elements.
• This allows you to set a particular style for many HTML
elements with the same class.
• The class selector uses the HTML class attribute, and is
defined with a "."
• In the example below, all HTML elements with class="center"
will be center-aligned:
The class Selector (Example)
• Imagine within the body element of our html page, we have the following
header element
• <h2 class=”center”>Summary</h2>
• We can then create a CSS rule with the class selector:
.center {text-align:center;}
• You can also specify that only specific HTML elements should be
affected by a class.
• In the example below, all p elements with class="center" will be center-
aligned:
Example
p.center {text-align:center;}
Tables
Steps to create table in CSS
• Use the HTML <table> element to define a table.
• Use the HTML <tr> element to define a table row.
• Use the HTML <td> element to define a table data.
• Use the HTML <th> element to define a table heading.
• Use the HTML <caption> element to define a table caption.
• Use the CSS border property to define a border.
Table Properties
• 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.
• 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.
Example of table creation in CSS
• <TABLE>
• <CAPTION>This is a simple 3x3 table</CAPTION>
• <TR id="row1">
• <TH>Header 1 <TD>Cell 1 <TD>Cell 2
• <TR id="row2">
• <TH>Header 2 <TD>Cell 3 <TD>Cell 4
• <TR id="row3">
• <TH>Header 3 <TD>Cell 5 <TD>Cell 6
• </TABLE>
Example of “Lists” in CSS
ul.circle {list-style-type: circle;}
ul.square {list-style-type: square;}
ol.upper-roman {list-style-type: upper-roman;}
ol.lower-alpha {list-style-type: lower-alpha;}
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
• Explanation of the different parts:
• 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
• The box model allows us to add a border around elements, and to
define space between elements.
• div {
width: 300px;
border: 15px solid green;
padding: 50px;
margin: 20px;
}
CSS

More Related Content

What's hot

CSS
CSSCSS
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
Swati Sharma
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
Michael Jhon
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Evolution Network
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
FaysalAhammed5
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
abhilashagupta
 
Html coding
Html codingHtml coding
Html coding
Briana VanBuskirk
 
html-css
html-csshtml-css
Css
CssCss
Html & CSS
Html & CSSHtml & CSS
Html & CSS
JainilSampat
 
Lecture 2 introduction to html
Lecture 2  introduction to htmlLecture 2  introduction to html
Lecture 2 introduction to html
palhaftab
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Folasade Adedeji
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
Singsys Pte Ltd
 

What's hot (20)

CSS
CSSCSS
CSS
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
CSS
CSSCSS
CSS
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
 
Html
HtmlHtml
Html
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
Html coding
Html codingHtml coding
Html coding
 
html-css
html-csshtml-css
html-css
 
Css
CssCss
Css
 
Html & CSS
Html & CSSHtml & CSS
Html & CSS
 
Lecture 2 introduction to html
Lecture 2  introduction to htmlLecture 2  introduction to html
Lecture 2 introduction to html
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 

Similar to CSS

CSS tutorial chapter 1
CSS tutorial chapter 1CSS tutorial chapter 1
CSS tutorial chapter 1
jeweltutin
 
CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
M Ashraful Islam Jewel
 
Css introduction
Css  introductionCss  introduction
Css introduction
vishnu murthy
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
CSS notes
CSS notesCSS notes
CSS notes
Rajendra Prasad
 
Css
CssCss
Css
CssCss
Css Basics
Css BasicsCss Basics
Css Basics
Jay Patel
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
shabab shihan
 
WT CSS
WT  CSSWT  CSS
WT CSS
Mohan186867
 
CSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.ECSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.E
NavyaEnugala
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
Programmer Blog
 
CSS Presentation Notes.pptx
CSS Presentation Notes.pptxCSS Presentation Notes.pptx
CSS Presentation Notes.pptx
VineetaSingh713208
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 

Similar to CSS (20)

CSS
CSSCSS
CSS
 
CSS tutorial chapter 1
CSS tutorial chapter 1CSS tutorial chapter 1
CSS tutorial chapter 1
 
CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
 
Css
CssCss
Css
 
Css.prabu
Css.prabuCss.prabu
Css.prabu
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
 
CSS notes
CSS notesCSS notes
CSS notes
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Css Basics
Css BasicsCss Basics
Css Basics
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
 
CSS
CSSCSS
CSS
 
WT CSS
WT  CSSWT  CSS
WT CSS
 
CSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.ECSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.E
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
 
CSS Presentation Notes.pptx
CSS Presentation Notes.pptxCSS Presentation Notes.pptx
CSS Presentation Notes.pptx
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
 
CSS
CSSCSS
CSS
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 

More from DivyaKS12

NUMBER SYSTEM.pptx
NUMBER SYSTEM.pptxNUMBER SYSTEM.pptx
NUMBER SYSTEM.pptx
DivyaKS12
 
unit 3.pptx
unit 3.pptxunit 3.pptx
unit 3.pptx
DivyaKS12
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptx
DivyaKS12
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
DivyaKS12
 
DBMS-INTRODUCTION.pptx
DBMS-INTRODUCTION.pptxDBMS-INTRODUCTION.pptx
DBMS-INTRODUCTION.pptx
DivyaKS12
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
DivyaKS12
 
Operation research (definition, phases)
Operation research (definition, phases)Operation research (definition, phases)
Operation research (definition, phases)
DivyaKS12
 
Types of Computer Modem
Types of Computer ModemTypes of Computer Modem
Types of Computer Modem
DivyaKS12
 
UI controls in Android
UI controls in Android UI controls in Android
UI controls in Android
DivyaKS12
 
Fragments In Android
Fragments In AndroidFragments In Android
Fragments In Android
DivyaKS12
 
Android os(comparison all other mobile os)
Android os(comparison all other mobile os)Android os(comparison all other mobile os)
Android os(comparison all other mobile os)
DivyaKS12
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
DivyaKS12
 
Internet technology
Internet technologyInternet technology
Internet technology
DivyaKS12
 

More from DivyaKS12 (13)

NUMBER SYSTEM.pptx
NUMBER SYSTEM.pptxNUMBER SYSTEM.pptx
NUMBER SYSTEM.pptx
 
unit 3.pptx
unit 3.pptxunit 3.pptx
unit 3.pptx
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptx
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
DBMS-INTRODUCTION.pptx
DBMS-INTRODUCTION.pptxDBMS-INTRODUCTION.pptx
DBMS-INTRODUCTION.pptx
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
 
Operation research (definition, phases)
Operation research (definition, phases)Operation research (definition, phases)
Operation research (definition, phases)
 
Types of Computer Modem
Types of Computer ModemTypes of Computer Modem
Types of Computer Modem
 
UI controls in Android
UI controls in Android UI controls in Android
UI controls in Android
 
Fragments In Android
Fragments In AndroidFragments In Android
Fragments In Android
 
Android os(comparison all other mobile os)
Android os(comparison all other mobile os)Android os(comparison all other mobile os)
Android os(comparison all other mobile os)
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Internet technology
Internet technologyInternet technology
Internet technology
 

Recently uploaded

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 

CSS

  • 2. Contents • Introduction • Internal style sheet • External style sheet • Controlling Text • Text Formatting • Selectors • Box Model • Backgrounds • Tables • Lists
  • 3. Introduction to CSS • What is meant by CSS? CSS stands for Cascading Style Sheets. CSS describes how HTML elements are to be displayed on screen, on paper, or in other media. CSS saves a lot of work. It can control the layout of multiple Web pages all at once
  • 4. What is a cascading style sheet? Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to Web documents.
  • 6.
  • 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.
  • 10. THREE WAYS TO INSERT CSS There are three ways of inserting a style sheet: • External style sheet • Internal style sheet • Inline style
  • 11.
  • 12. Internal Style sheet First we will explore the internal method. This way you are simply placing the CSS code within the <head></head> tags of each (X)HTML file you want to style with the CSS. The format for this is shown in the example below: <head> <title><title> <style type=”text/css”> CSS Content Goes Here </style> </head> <body> With this method each (X)HTML file contains the CSS code needed to style the page. Meaning that any changes you want to make to one page, will have to be made to all. This method can be good if you need to style only one page, or if you want different pages to have varying styles.
  • 13. External Style sheet Next we will explore the external method. An external CSS file can be created with any text or HTML editor such as “Notepad” or “Dreamweaver”. A CSS file contains no (X)HTML, only CSS. You simply save it with the .css file extension. You can link to the file externally by placing one of the following links in the head section of every (X)HTML file you want to style with the CSS file. <link rel=”stylesheet” type=”text/css” href=“Path To stylesheet.css” /> Or you can also use the @import method as shown below <style type=”text/css”>@import url(Path To stylesheet.css)</style>
  • 14. External Style sheet (contd..) By using an external style sheet, all of your (X)HTML files link to one CSS file in order to style the pages. This means, that if you need to alter the design of all your pages, you only need to edit one .css file to make global changes to your entire website. • Here are a few reasons this is better. • Easier Maintenance • Reduced File Size • Reduced Bandwidth • Improved Flexibility
  • 15. CSS Syntax A CSS rule has two main parts: a selector, and one or more declarations: The selector is normally the HTML element you want to style. Each declaration consists of a property and a value. The property is the style attribute you want to change. Each property has a value. CSS declarations always ends with a semicolon, and declaration groups are surrounded by curly brackets: p {color:red;text-align:center;}
  • 16. CSS STYLINGBackground Color The background-color property specifies the background color of an element. The background color of a page is defined in the body selector: Example body {background-color:#b0c4de;} The background color can be specified by: * name - a color name, like "red" * RGB - an RGB value, like "rgb(255,0,0)" * Hex - a hex value, like "#ff0000"
  • 17.
  • 18. Background image The background-image property specifies an image to use as the background of an element. By default, the image is repeated so it covers the entire element. The background image for a page can be set like this: Example Body {background-image:url('paper.Gif');} Below is an example of a bad combination of text and background image.
  • 19. Example body {background-image:url('bgdesert.jpg');} Background Image - Repeat Horizontally or Vertically By default, the background-image property repeats an image both horizontally and vertically. Some images should be repeated only horizontally or vertically, or they will look strange: Example body { background-image:url('gradient2.png'); }
  • 20. Background Image - Set position and no-repeat Remark When using a background image, use an image that does not disturb the text. Showing the image only once is specified by the background-repeat property: Example body { background-image:url('img_tree.png'); background-repeat:no-repeat; }
  • 21. Background - Shorthand property As you can see from the examples above, there are many properties to consider when dealing with backgrounds. To shorten the code, it is also possible to specify all the properties in one single property. This is called a shorthand property. The shorthand property for background is simply "background": Example body {background:#ffffff url('img_tree.png') no-repeat right top;}
  • 22. Text Color The color property is used to set the color of the text. The color can be specified by: * name - a color name, like "red" * RGB - an RGB value, like "rgb(255,0,0)" * Hex - a hex value, like "#ff0000" The default color for a page is defined in the body selector. Example body {color:blue;} h1 {color:#00ff00;} h2 {color:rgb(255,0,0);}
  • 23. Text Alignment The text-align property is used to set the horizontal alignment of a text. Text can be centered, or aligned to the left or right, or justified. When text-align is set to "justify", each line is stretched so that every line has equal width, and the left and right margins are straight (like in magazines and newspapers). Example h1 {text-align:center;} h2 {text-align:right;} h3 {text-align:justify;}
  • 24. Text Decoration The text-decoration property is used to set or remove decorations from text. The text-decoration property is mostly used to remove underlines from links for design purposes: Example a {text-decoration:none;} It can also be used to decorate text: Example : h1 {text-decoration:overline;} h3 {text-decoration:underline;} h4 {text-decoration:blink;}
  • 25. Text Transformation The text-transform property is used to specify uppercase and lowercase letters in a text. It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word. Example p.uppercase {text-transform:uppercase;} p.lowercase {text-transform:lowercase;} p.capitalize {text-transform:capitalize;}
  • 26. CSS Font Families In CSS, there are two types of font family names: * generic family - a group of font families with a similar look (like "Serif" or "Monospace") * font family - a specific font family (like "Times New Roman" or "Arial") Font Family The font family of a text is set with the font-family property. The font-family property should hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font. Start with the font you want, and end with a generic family, to let the browser pick a similar font in the generic family, if no other fonts are available. Note: If the name of a font family is more than one word, it must be in quotation marks, like font-family: "Times New Roman". More than one font family is specified in a comma-separated list: Example : p{font-family:"Times New Roman", Times, serif;}
  • 27. Font Style The font-style property is mostly used to specify italic text. This property has three values: * normal - The text is shown normally * italic - The text is shown in italics Example : p.normal {font-style:normal;} p.italic {font-style:italic;}
  • 28. Font Size The font-size property sets the size of the text. Being able to manage the text size is important in web design. However, you should not use font size adjustments to make paragraphs look like headings, or headings look like paragraphs. Always use the proper HTML tags, like <h1> - <h6> for headings and <p> for paragraphs. The font-size value can be an absolute, or relative size.
  • 29. Set Font Size With Pixels Setting the text size with pixels, gives you full control over the text size: Example : h1 {font-size:40px;} h2 {font-size:30px;} p {font-size:14px;} Set Font Size With Em To avoid the resizing problem with Internet Explorer, many developers use Em instead of pixels. The Em size unit is recommended by the W3C. 1 Em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px. The size can be calculated from pixels to Em using this formula: pixels/16=Em Example : h1 {font-size:2.5em;} /* 40px/16=2.5em */ h2 {font-size:1.875em;} /* 30px/16=1.875em */ p {font-size:0.875em;} /* 14px/16=0.875em */
  • 30. CSS Selectors • Three types of CSS Selectors • Element • Class • ID
  • 31. CSS Element Selector • A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets: • p {color:red;text-align:center;} • To make the CSS more readable, you can put one declaration on each line, like this: • p { color:red; text-align:center; }
  • 32. CSS Comments • Comments are used to explain your code, and may help you when you edit the source code at a later date. Comments are ignored by browsers. • A CSS comment begins with "/*", and ends with "*/", like this: • /*This is a comment*/ p { text-align:center; /*This is another comment*/ color:black;}
  • 33. The id and class Selectors • In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class". • id is used when we have to apply CSS property to one attribute only. • class is used when we have to use CSS property in many locations within the same page or different.
  • 34. CSS Syntax #id {css declarations;} EX. #firstname { backgroundcolor: yellow;}
  • 35. The id Selector • The id selector is used to specify a style for a single, unique element. • The id selector uses the id attribute of the HTML element, and is defined with a "#". • Example • Imagine within the body element of our html page, we have the following paragraph element • <p id=”welcome”>Welcome to the wonderful world of HTML</p> • We can then create a CSS rule with the id selector: • #welcome { text-align:center; color:red; }
  • 36. The class Selector • The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. • This allows you to set a particular style for many HTML elements with the same class. • The class selector uses the HTML class attribute, and is defined with a "." • In the example below, all HTML elements with class="center" will be center-aligned:
  • 37. The class Selector (Example) • Imagine within the body element of our html page, we have the following header element • <h2 class=”center”>Summary</h2> • We can then create a CSS rule with the class selector: .center {text-align:center;} • You can also specify that only specific HTML elements should be affected by a class. • In the example below, all p elements with class="center" will be center- aligned: Example p.center {text-align:center;}
  • 38.
  • 39. Tables Steps to create table in CSS • Use the HTML <table> element to define a table. • Use the HTML <tr> element to define a table row. • Use the HTML <td> element to define a table data. • Use the HTML <th> element to define a table heading. • Use the HTML <caption> element to define a table caption. • Use the CSS border property to define a border.
  • 40. Table Properties • 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. • 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.
  • 41. Example of table creation in CSS • <TABLE> • <CAPTION>This is a simple 3x3 table</CAPTION> • <TR id="row1"> • <TH>Header 1 <TD>Cell 1 <TD>Cell 2 • <TR id="row2"> • <TH>Header 2 <TD>Cell 3 <TD>Cell 4 • <TR id="row3"> • <TH>Header 3 <TD>Cell 5 <TD>Cell 6 • </TABLE>
  • 42. Example of “Lists” in CSS ul.circle {list-style-type: circle;} ul.square {list-style-type: square;} ol.upper-roman {list-style-type: upper-roman;} ol.lower-alpha {list-style-type: lower-alpha;}
  • 43. 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
  • 44.
  • 45.
  • 46. • Explanation of the different parts: • 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 • The box model allows us to add a border around elements, and to define space between elements.
  • 47. • div { width: 300px; border: 15px solid green; padding: 50px; margin: 20px; }