SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
Cascading Style Sheets
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
Introduction
• CSS stands for Cascading Style Sheets.
• Styles define how to display HTML elements.
• External Style Sheets can save a lot of work.
• External Style Sheets are stored in CSS files.
Styles Solved a Big Problem
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• HTML was never intended to contain tags for formatting
a document.
• HTML was intended to define the content of a document,
like:<h1>This is a heading</h1>
• tags like <font>, and color attributes were added to the
HTML 3.2 specification.
• In HTML 4.0, all formatting could be removed from the
HTML document, and stored in a separate CSS file.
All browsers support CSS today
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• General form:
• Example:
CSS Structure
p {color:red;text-align:center;}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS syntax
• Element selector:
The element selector selects elements based on the element name.
• Example:
CSS Structure
<p > This is a paragraph </p>
p {
text-align:center;
color:red;
}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Selectors
You can select all <p> elements
on a page like this: (all <p>
elements will be center-aligned,
with a red text color)
• Id selector:
The id selector uses the id attribute of an HTML tag to find the specific
element.
• Example:
CSS Structure
#para1 {
text-align: center;
color: red;
}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Selectors
The style rule below will be
applied to the HTML element
with id="para1":
• Class selector:
The class selector finds elements with the specific class.
• Example:
CSS Structure
.center {
text-align: center;
color: red;
}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Selectors
You can specify that only specific
HTML elements should be
affected by a class.
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• Inline style.
• Internal style sheet.
• External style sheet.
Three Ways to Insert CSS
CSS Structure
CSS Structure
Inline style
<p style="color:sienna;margin-left:20px;">This is a paragraph.</p>
HTML page:
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Structure
Internal style sheet
<head>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/background.gif");}
</style>
</head>
HTML page:
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Structure
External style sheet
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
HTML page:
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/background.gif");}
CSS file:
CSS Structure
background properties
background-color:
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
body {background-image:url("paper.gif");}
body {background-color:#b0c4de;}
background-image:
CSS Structure
background properties
Set position and repeat
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
body{
background-image:url("img_tree.png");
background-repeat:no-repeat;
background-position:right top;}
CSS Structure
Text properties
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
body{color:blue
text-align:center;
direction:rtl;
}
CSS Structure
Font properties
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
body{font-family:Tahoma;
font-style:normal;
font-size:40px;
}
CSS Structure
Link properties
• links can be styled differently depending on
what state they are in.
• a:link - a normal, unvisited link
• a:visited - a link the user has visited
• a:hover - a link when the user mouses over it
• a:active - a link the moment it is clicked
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Structure
Link properties
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
a:link {color:#B2FF99;}
a:visited {color:#FFFF85;}
a:hover {color:#FF704D; text-decoration:none;}
a:active {color:#FF704D;}
CSS Structure
List properties
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
ul{
list-style-type: none;
padding: 0px;
margin: 0px;}
ul li{
background-image: url(sqpurple.gif);
background-repeat: no-repeat;
background-position: 0px 5px;
padding-left: 14px;
display: inline;}
CSS Structure
Table Border
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
table, th, td {
border: 1px solid black;
}
Collapse Borders :
table {
border-collapse: collapse;
}
The border-collapse property sets
whether the table borders are collapsed
into a single border or separated
CSS Structure
Box Model
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
•Margin Clears an area around the border. The margin does not have a
background color, it is completely transparent
•Border A border that goes around the padding and content. The border
is inherited from the color property of the box
•Padding Clears an area around the content. The padding is affected by
the background color of the box
•Content The content of the box, where text and images appear
CSS Structure
Box Model
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• Individual sides:
• Shorthand property:
CSS Structure
margin-top:100px;
margin-right:50px;
margin-bottom:100px;
margin-left:50px;
Margin
margin:100px 50px 100px 50px;
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• Individual sides:
• Shorthand property:
CSS Structure
p{border-width:5px;
border-style:solid;
border-color:red;
border-bottom-style:dotted;}
Border
border:5px solid red;
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
CSS Structure
Border-Style values
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• Individual sides:
• Shorthand property:
CSS Structure
padding-top:25px;
padding-right:50px;
padding-bottom:25px;
padding-left:50px;
Padding
padding:25px 50px 25px 50px;
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• With CSS float, an element can be pushed to the left or right,
allowing other elements to wrap around it.
• Float is very often used for images, but it is also useful when
working with layouts.
• Turning off Float - Using Clear :Elements after the floating element
will flow around it. To avoid this, use the clear property.
CSS Structure
img {float: right;}
Floating
.clear {clear: both;}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• visibility:hidden hides an element, but it will still take up the same
space as before. The element will be hidden, but still affect the
layout:
• display:none hides an element, and it will not take up any space.
The element will be hidden, and the page will be displayed as if the
element is not there:
CSS Structure
h1.hidden {visibility:hidden;}
Display and Visibility
h1.hidden {display:none;}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• The CSS positioning properties allow you to position an element. It
can also place an element behind another, and specify what should
happen when an element's content is too big.
• There are four different positioning methods.
 Static Positioning
 Fixed Positioning
 Relative Positioning
 Absolute Positioning
CSS Structure
Positioning
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• HTML elements are positioned static by default. A static positioned
element is always positioned according to the normal flow of the
page.
• Static positioned elements are not affected by the top, bottom, left,
and right properties.
CSS Structure
Static Positioning
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• An element with fixed position is positioned relative to the browser
window.
• It will not move even if the window is scrolled.
• Fixed positioned elements can overlap other elements.
CSS Structure
Fixed Positioning
p.pos_fixed {
position: fixed;
top: 30px;
right: 5px;
}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• A relative positioned element is positioned relative to its normal
position.
• Relatively positioned elements are often used as container blocks
for absolutely positioned elements.
CSS Structure
Relative Positioning
h2.pos_right {
position: relative;
left: 20px;
}
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
• An absolute position element is positioned relative to the first parent
element that has a position other than static. If no such element is
found, the containing block is <html>:
• Relatively positioned elements are often used as container blocks
for absolutely positioned elements.
CSS Structure
Absolute Positioning
h2 { position: absolute;
left: 100px;
top: 150px; }
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
Notes
1 Don’t forget saving file in .css format.
2 We will see the output in the browser.
Let’s Test it live !
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh

Contenu connexe

Tendances

Dynamic websites lec5
Dynamic websites lec5Dynamic websites lec5
Dynamic websites lec5
Belal Arfa
 

Tendances (20)

Introduction to PHP - Slide 1
Introduction to PHP - Slide 1 Introduction to PHP - Slide 1
Introduction to PHP - Slide 1
 
How We Localize & Mobilize WP Sites - Pubcon 2013
How We Localize & Mobilize WP Sites - Pubcon 2013How We Localize & Mobilize WP Sites - Pubcon 2013
How We Localize & Mobilize WP Sites - Pubcon 2013
 
Web development
Web developmentWeb development
Web development
 
Web Development basics with WordPress
Web Development basics with WordPressWeb Development basics with WordPress
Web Development basics with WordPress
 
DM 250 Week 1 - The Internet, XHTML, & CSS
DM 250 Week 1 - The Internet, XHTML, & CSSDM 250 Week 1 - The Internet, XHTML, & CSS
DM 250 Week 1 - The Internet, XHTML, & CSS
 
Web Development
Web DevelopmentWeb Development
Web Development
 
Javascript
JavascriptJavascript
Javascript
 
HTML- Hyper Text Markup Language
HTML- Hyper Text Markup LanguageHTML- Hyper Text Markup Language
HTML- Hyper Text Markup Language
 
CSS- Cascading Style Sheet
CSS- Cascading Style SheetCSS- Cascading Style Sheet
CSS- Cascading Style Sheet
 
Dynamic websites lec5
Dynamic websites lec5Dynamic websites lec5
Dynamic websites lec5
 
Khoa dang (kay)
Khoa dang (kay)Khoa dang (kay)
Khoa dang (kay)
 
Trends and Insights for Interactive Email & Google AMP for Email
Trends and Insights for Interactive Email & Google AMP for EmailTrends and Insights for Interactive Email & Google AMP for Email
Trends and Insights for Interactive Email & Google AMP for Email
 
Keep the Web Fast
Keep the Web FastKeep the Web Fast
Keep the Web Fast
 
Introduction to html class-1
Introduction to html class-1Introduction to html class-1
Introduction to html class-1
 
Ajax
AjaxAjax
Ajax
 
Intro to HTML
Intro to HTMLIntro to HTML
Intro to HTML
 
WEBD 162: What is a Web Page?
WEBD 162: What is a Web Page?WEBD 162: What is a Web Page?
WEBD 162: What is a Web Page?
 
Fixing common problems with SEO by Steve Mortiboy
Fixing common problems with SEO by Steve MortiboyFixing common problems with SEO by Steve Mortiboy
Fixing common problems with SEO by Steve Mortiboy
 
Html.ppt
Html.pptHtml.ppt
Html.ppt
 
WEBD 162 Week 02 LWD4e
WEBD 162 Week 02 LWD4eWEBD 162 Week 02 LWD4e
WEBD 162 Week 02 LWD4e
 

Similaire à Php workshop L01 CSS

Web programming css
Web programming cssWeb programming css
Web programming css
Uma mohan
 

Similaire à Php workshop L01 CSS (20)

BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptx
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
 
CSS
CSSCSS
CSS
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
BITM3730 9-26.pptx
BITM3730 9-26.pptxBITM3730 9-26.pptx
BITM3730 9-26.pptx
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By Mukesh
 
Css intro
Css introCss intro
Css intro
 
BITM3730Week4.pptx
BITM3730Week4.pptxBITM3730Week4.pptx
BITM3730Week4.pptx
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSS
 
BITM3730 9-27.pptx
BITM3730 9-27.pptxBITM3730 9-27.pptx
BITM3730 9-27.pptx
 
Web 102 INtro to CSS
Web 102  INtro to CSSWeb 102  INtro to CSS
Web 102 INtro to CSS
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
Css
CssCss
Css
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
css.ppt
css.pptcss.ppt
css.ppt
 
Basic HTML/CSS
Basic HTML/CSSBasic HTML/CSS
Basic HTML/CSS
 
Cascading style sheet an introduction
Cascading style sheet   an introductionCascading style sheet   an introduction
Cascading style sheet an introduction
 
Web programming css
Web programming cssWeb programming css
Web programming css
 

Plus de Mohammad Tahsin Alshalabi

Plus de Mohammad Tahsin Alshalabi (14)

NUMA optimized Parallel Breadth first Search on Multicore Single node System
NUMA optimized Parallel Breadth first Search on Multicore Single node SystemNUMA optimized Parallel Breadth first Search on Multicore Single node System
NUMA optimized Parallel Breadth first Search on Multicore Single node System
 
Learning Management System in Damascus University-Information Technology Engi...
Learning Management System in Damascus University-Information Technology Engi...Learning Management System in Damascus University-Information Technology Engi...
Learning Management System in Damascus University-Information Technology Engi...
 
Learning management system in information technology engineering faculty
Learning management system in  information technology engineering facultyLearning management system in  information technology engineering faculty
Learning management system in information technology engineering faculty
 
Moodle documentation
Moodle documentationMoodle documentation
Moodle documentation
 
Moodle plugins programing manual
Moodle plugins programing manualMoodle plugins programing manual
Moodle plugins programing manual
 
CodeIgniter L5 email & user agent & security
CodeIgniter L5 email & user agent & securityCodeIgniter L5 email & user agent & security
CodeIgniter L5 email & user agent & security
 
CodeIgniter L4 file upload & image manipulation & language
CodeIgniter L4 file upload & image manipulation & languageCodeIgniter L4 file upload & image manipulation & language
CodeIgniter L4 file upload & image manipulation & language
 
CodeIgniter L3 model & active record & template
CodeIgniter L3 model & active record  & templateCodeIgniter L3 model & active record  & template
CodeIgniter L3 model & active record & template
 
CodeIgniter L2 helper & libraries & form validation
CodeIgniter L2 helper & libraries & form validation CodeIgniter L2 helper & libraries & form validation
CodeIgniter L2 helper & libraries & form validation
 
CodeIgniter L1 introduction to CodeIgniter framework
CodeIgniter L1 introduction to CodeIgniter frameworkCodeIgniter L1 introduction to CodeIgniter framework
CodeIgniter L1 introduction to CodeIgniter framework
 
Comparison between web and mobile application requirements
Comparison between web and mobile application requirementsComparison between web and mobile application requirements
Comparison between web and mobile application requirements
 
Introduction to web services
Introduction to web servicesIntroduction to web services
Introduction to web services
 
Php workshop L04 database
Php workshop L04 databasePhp workshop L04 database
Php workshop L04 database
 
Php workshop L03 superglobals
Php workshop L03 superglobalsPhp workshop L03 superglobals
Php workshop L03 superglobals
 

Dernier

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

Php workshop L01 CSS

  • 2. By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh Introduction • CSS stands for Cascading Style Sheets. • Styles define how to display HTML elements. • External Style Sheets can save a lot of work. • External Style Sheets are stored in CSS files.
  • 3. Styles Solved a Big Problem By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh • HTML was never intended to contain tags for formatting a document. • HTML was intended to define the content of a document, like:<h1>This is a heading</h1> • tags like <font>, and color attributes were added to the HTML 3.2 specification. • In HTML 4.0, all formatting could be removed from the HTML document, and stored in a separate CSS file.
  • 4. All browsers support CSS today By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 5. • General form: • Example: CSS Structure p {color:red;text-align:center;} By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh CSS syntax
  • 6. • Element selector: The element selector selects elements based on the element name. • Example: CSS Structure <p > This is a paragraph </p> p { text-align:center; color:red; } By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh CSS Selectors You can select all <p> elements on a page like this: (all <p> elements will be center-aligned, with a red text color)
  • 7. • Id selector: The id selector uses the id attribute of an HTML tag to find the specific element. • Example: CSS Structure #para1 { text-align: center; color: red; } By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh CSS Selectors The style rule below will be applied to the HTML element with id="para1":
  • 8. • Class selector: The class selector finds elements with the specific class. • Example: CSS Structure .center { text-align: center; color: red; } By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh CSS Selectors You can specify that only specific HTML elements should be affected by a class.
  • 9. By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh • Inline style. • Internal style sheet. • External style sheet. Three Ways to Insert CSS CSS Structure
  • 10. CSS Structure Inline style <p style="color:sienna;margin-left:20px;">This is a paragraph.</p> HTML page: By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 11. CSS Structure Internal style sheet <head> <style> hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/background.gif");} </style> </head> HTML page: By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 12. CSS Structure External style sheet <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> HTML page: By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/background.gif");} CSS file:
  • 13. CSS Structure background properties background-color: By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh body {background-image:url("paper.gif");} body {background-color:#b0c4de;} background-image:
  • 14. CSS Structure background properties Set position and repeat By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh body{ background-image:url("img_tree.png"); background-repeat:no-repeat; background-position:right top;}
  • 15. CSS Structure Text properties By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh body{color:blue text-align:center; direction:rtl; }
  • 16. CSS Structure Font properties By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh body{font-family:Tahoma; font-style:normal; font-size:40px; }
  • 17. CSS Structure Link properties • links can be styled differently depending on what state they are in. • a:link - a normal, unvisited link • a:visited - a link the user has visited • a:hover - a link when the user mouses over it • a:active - a link the moment it is clicked By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 18. CSS Structure Link properties By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh a:link {color:#B2FF99;} a:visited {color:#FFFF85;} a:hover {color:#FF704D; text-decoration:none;} a:active {color:#FF704D;}
  • 19. CSS Structure List properties By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh ul{ list-style-type: none; padding: 0px; margin: 0px;} ul li{ background-image: url(sqpurple.gif); background-repeat: no-repeat; background-position: 0px 5px; padding-left: 14px; display: inline;}
  • 20. CSS Structure Table Border By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh table, th, td { border: 1px solid black; } Collapse Borders : table { border-collapse: collapse; } The border-collapse property sets whether the table borders are collapsed into a single border or separated
  • 21. CSS Structure Box Model By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh •Margin Clears an area around the border. The margin does not have a background color, it is completely transparent •Border A border that goes around the padding and content. The border is inherited from the color property of the box •Padding Clears an area around the content. The padding is affected by the background color of the box •Content The content of the box, where text and images appear
  • 22. CSS Structure Box Model By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 23. • Individual sides: • Shorthand property: CSS Structure margin-top:100px; margin-right:50px; margin-bottom:100px; margin-left:50px; Margin margin:100px 50px 100px 50px; By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 24. • Individual sides: • Shorthand property: CSS Structure p{border-width:5px; border-style:solid; border-color:red; border-bottom-style:dotted;} Border border:5px solid red; By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 25. CSS Structure Border-Style values By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 26. • Individual sides: • Shorthand property: CSS Structure padding-top:25px; padding-right:50px; padding-bottom:25px; padding-left:50px; Padding padding:25px 50px 25px 50px; By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 27. • With CSS float, an element can be pushed to the left or right, allowing other elements to wrap around it. • Float is very often used for images, but it is also useful when working with layouts. • Turning off Float - Using Clear :Elements after the floating element will flow around it. To avoid this, use the clear property. CSS Structure img {float: right;} Floating .clear {clear: both;} By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 28. • visibility:hidden hides an element, but it will still take up the same space as before. The element will be hidden, but still affect the layout: • display:none hides an element, and it will not take up any space. The element will be hidden, and the page will be displayed as if the element is not there: CSS Structure h1.hidden {visibility:hidden;} Display and Visibility h1.hidden {display:none;} By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 29. • The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big. • There are four different positioning methods.  Static Positioning  Fixed Positioning  Relative Positioning  Absolute Positioning CSS Structure Positioning By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 30. • HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page. • Static positioned elements are not affected by the top, bottom, left, and right properties. CSS Structure Static Positioning By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 31. • An element with fixed position is positioned relative to the browser window. • It will not move even if the window is scrolled. • Fixed positioned elements can overlap other elements. CSS Structure Fixed Positioning p.pos_fixed { position: fixed; top: 30px; right: 5px; } By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 32. • A relative positioned element is positioned relative to its normal position. • Relatively positioned elements are often used as container blocks for absolutely positioned elements. CSS Structure Relative Positioning h2.pos_right { position: relative; left: 20px; } By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 33. • An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>: • Relatively positioned elements are often used as container blocks for absolutely positioned elements. CSS Structure Absolute Positioning h2 { position: absolute; left: 100px; top: 150px; } By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
  • 34. Notes 1 Don’t forget saving file in .css format. 2 We will see the output in the browser. Let’s Test it live ! By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh