SlideShare ist ein Scribd-Unternehmen logo
1 von 17
www.afghanhost.af - info@afghanhost.af
Instructor: Mohammad Rafi Haidari28-May-2014
CSS (Day 1)
 What is CSS
 CSS Syntax
 Selectors
 Ways to Insert CSS
 Backgrounds
CSS Introduction
 CSS stands for Cascading Style Sheets
 Styles define how to display HTML elements
 Styles were added to HTML 4.0 to solve a problem
 External Style Sheets can save a lot of work
 External Style Sheets are stored in CSS files
CSS Saves a Lot of Work!
CSS defines HOW HTML elements are to be displayed.
Styles are normally saved in external .css files. External style
sheets enable you to change the appearance and layout of all
the pages in a Web site, just by editing one single file!
CSS Syntax
 A CSS rule set consists of a selector and a declaration block:
 The selector points to the HTML element you want to style.
 The declaration block contains one or more declarations
separated by semicolons.
 Each declaration includes a property name and a value,
separated by a colon.
CSS Selectors
 CSS selectors allow you to select and manipulate HTML
element(s).
 CSS selectors are used to "find" (or select) HTML elements
based on their id, classes, types, attributes, values of
attributes and much more.
The element Selector
The element selector selects elements based on the element
name.
You can select all <p> elements on a page like this: (all <p>
elements will be center-aligned, with a red text color)
p
{
text-align:center;
CSS Selectors
The id Selector
The id selector uses the id attribute of an HTML tag to find the
specific element.
An id should be unique within a page, so you should use the id
selector when you want to find a single, unique element.
To find an element with a specific id, write a hash character, followed
by the id of the element.
The style rule below will be applied to the HTML element with
id="para1":
#para1
{
text-align:center;
color:red;
}
CSS Selectors
The class Selector
The class selector finds elements with the specific class.
The class selector uses the HTML class attribute.
To find elements with a specific class, write a period character,
followed by the name of the class:
In the example below, all HTML elements with class="center"
will be center-aligned:
.center
{
text-align:center;
color:red;
}
CSS Selectors
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:
p.center
{
text-align:center;
color:red;
}
Note: Do NOT start a class name with a number!
CSS Selectors
 Grouping Selectors
 In style sheets there are often elements with the same style:
h1
{
text-align:center;
color:red;
}
h2
{
text-align:center;
color:red;
}
p
{
text-align:center;
color:red;
}
To minimize the code, you can group selectors.
To group selectors, separate each selector with a
comma.
In the example below we have grouped the selectors
from the code leftside:
h1,h2,p
{
text-align:center;
color:red;
Ways to Insert CSS
There are three ways of inserting a style sheet:
 External style sheet
 Internal style sheet
 Inline style
External Style Sheet
An external style sheet is ideal when the style is applied to many
pages. With an external style sheet, you can change the look of an
entire Web site by changing one file. Each page must link to the style
sheet using the <link> tag. The <link> tag goes inside the head
section:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Ways to Insert CSS
Note: An external style sheet can be written in any text editor.
The file should not contain any html tags. Your style sheet
should be saved with a .css extension. An example of a style
sheet file is shown below:
hr {color:blue;}
p {margin-left:20px;}
body {background-image:url("images/background.gif");}
Note:Do not add a space between the property value and the
unit (such as margin-left:20 px). The correct way is: margin-
Ways to Insert CSS
Internal Style Sheet
An internal style sheet should be used when a single document
has a unique style. You define internal styles in the head section
of an HTML page, by using the <style> tag, like this:
<head>
<style>
hr {color:blue;}
p {margin-left:20px;}
body {background-image:url("images/background.gif");}
</style>
</head>
Ways to Insert CSS
Inline Styles
An inline style loses many of the advantages of style sheets by
mixing content with presentation. Use this method sparingly!
To use inline styles you use the style attribute in the relevant
tag. The style attribute can contain any CSS property. The
example shows how to change the color and the left margin of a
paragraph:
<p style="color:blue;margin-left:20px;">This is a
paragraph.</p>
CSS Background
CSS background properties are used to define the background
effects of an element.
CSS properties used for background effects:
 background-color
 background-image
 background-repeat
 background-position
CSS Background
Background Color
The background-color property specifies the background color
of an element.
The background color of a page is defined in the body selector:
body {background-color:#b0c4de;}
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:
CSS Background
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, like this:
body
{
background-image:url("gradient.png");
}
If the image is repeated only horizontally (repeat-x), the background will look
better:
body
{
background-image:url("gradient.png");
background-repeat:repeat-x;
CSS Background
Set position and no-repeat
The position of the image is specified by the background-position property:
body
{
background-image:url("img_tree.png");
background-repeat:no-repeat;
background-position:right top;
}
Property Values
• left top
• left center
• left bottom
• right top
• right center
• right bottom
• center top
• center center
• center bottom
CSS_Day_ONE (W3schools)

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
 
CSS
CSS CSS
CSS
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSSCascading Style Sheets - CSS
Cascading Style Sheets - CSS
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
Css
CssCss
Css
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
Css ppt
Css pptCss ppt
Css ppt
 
Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
 
CSS
CSSCSS
CSS
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
 
CSS - Text Properties
CSS - Text PropertiesCSS - Text Properties
CSS - Text Properties
 
Web Design Course: CSS lecture 4
Web Design Course: CSS  lecture 4Web Design Course: CSS  lecture 4
Web Design Course: CSS lecture 4
 
What is CSS?
What is CSS?What is CSS?
What is CSS?
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Andere mochten auch

Records of the olympic field games (6)
Records of the olympic field games (6)Records of the olympic field games (6)
Records of the olympic field games (6)anagarridoaroz99
 
HTML_Day_Two(W3Schools)
HTML_Day_Two(W3Schools)HTML_Day_Two(W3Schools)
HTML_Day_Two(W3Schools)Rafi Haidari
 
ნიცშე 'ასე იტყოდა ზარატუსტრა'
ნიცშე 'ასე იტყოდა ზარატუსტრა'ნიცშე 'ასე იტყოდა ზარატუსტრა'
ნიცშე 'ასე იტყოდა ზარატუსტრა'Nini Sekhniashvili
 
New organic clothes image
New organic clothes imageNew organic clothes image
New organic clothes imageorganicproducts
 
Lose weight dieting success guaranteed
Lose weight dieting   success guaranteedLose weight dieting   success guaranteed
Lose weight dieting success guaranteedAljwadh Profo
 
Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...
Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...
Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...РОМЦ БКР
 
Historia juegos olimpicos59
Historia juegos olimpicos59Historia juegos olimpicos59
Historia juegos olimpicos59anagarridoaroz99
 

Andere mochten auch (16)

Bootstrap day2
Bootstrap day2Bootstrap day2
Bootstrap day2
 
Records of the olympic field games (6)
Records of the olympic field games (6)Records of the olympic field games (6)
Records of the olympic field games (6)
 
Women in science
Women in scienceWomen in science
Women in science
 
Final Project
Final ProjectFinal Project
Final Project
 
HTML_Day_Two(W3Schools)
HTML_Day_Two(W3Schools)HTML_Day_Two(W3Schools)
HTML_Day_Two(W3Schools)
 
ნიცშე 'ასე იტყოდა ზარატუსტრა'
ნიცშე 'ასე იტყოდა ზარატუსტრა'ნიცშე 'ასე იტყოდა ზარატუსტრა'
ნიცშე 'ასე იტყოდა ზარატუსტრა'
 
New organic clothes image
New organic clothes imageNew organic clothes image
New organic clothes image
 
Introduce my self
Introduce my selfIntroduce my self
Introduce my self
 
Onet eng
Onet engOnet eng
Onet eng
 
Pat5
Pat5Pat5
Pat5
 
Lose weight dieting success guaranteed
Lose weight dieting   success guaranteedLose weight dieting   success guaranteed
Lose weight dieting success guaranteed
 
งานK7 (1)
งานK7 (1)งานK7 (1)
งานK7 (1)
 
Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...
Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...
Лауреати обласної літературної премії імені Василя Симоненка (До 80-річчя від...
 
PowePoint
PowePointPowePoint
PowePoint
 
Historia juegos olimpicos59
Historia juegos olimpicos59Historia juegos olimpicos59
Historia juegos olimpicos59
 
Olympic games 22
Olympic games 22Olympic games 22
Olympic games 22
 

Ähnlich wie CSS_Day_ONE (W3schools)

Ähnlich wie CSS_Day_ONE (W3schools) (20)

chitra
chitrachitra
chitra
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
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
 
Introduction of css
Introduction of cssIntroduction of css
Introduction of css
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
 
CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
 
CSS tutorial chapter 1
CSS tutorial chapter 1CSS tutorial chapter 1
CSS tutorial chapter 1
 
HTML to CSS Basics Exer 2.pptx
HTML to CSS Basics Exer 2.pptxHTML to CSS Basics Exer 2.pptx
HTML to CSS Basics Exer 2.pptx
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
 
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
 
html-css
html-csshtml-css
html-css
 
Css
CssCss
Css
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Css basics
Css basicsCss basics
Css basics
 

Mehr von Rafi Haidari

Lecture9 web design and development
Lecture9 web design and developmentLecture9 web design and development
Lecture9 web design and developmentRafi Haidari
 
Lecture8 web design and development
Lecture8 web design and developmentLecture8 web design and development
Lecture8 web design and developmentRafi Haidari
 
Lecture7 web design and development
Lecture7 web design and developmentLecture7 web design and development
Lecture7 web design and developmentRafi Haidari
 
Lecture6 web design and development
Lecture6 web design and developmentLecture6 web design and development
Lecture6 web design and developmentRafi Haidari
 
Lecture5 web design and development
Lecture5 web design and developmentLecture5 web design and development
Lecture5 web design and developmentRafi Haidari
 
Lecture4 web design and development
Lecture4 web design and developmentLecture4 web design and development
Lecture4 web design and developmentRafi Haidari
 
Lecture3 web design and development
Lecture3 web design and developmentLecture3 web design and development
Lecture3 web design and developmentRafi Haidari
 
Lecture2 web design and development
Lecture2 web design and developmentLecture2 web design and development
Lecture2 web design and developmentRafi Haidari
 
Lecture1 Web Design and Development
Lecture1 Web Design and DevelopmentLecture1 Web Design and Development
Lecture1 Web Design and DevelopmentRafi Haidari
 
Html_Day_One (W3Schools)
Html_Day_One (W3Schools)Html_Day_One (W3Schools)
Html_Day_One (W3Schools)Rafi Haidari
 
Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)Rafi Haidari
 

Mehr von Rafi Haidari (13)

Lecture9 web design and development
Lecture9 web design and developmentLecture9 web design and development
Lecture9 web design and development
 
Lecture8 web design and development
Lecture8 web design and developmentLecture8 web design and development
Lecture8 web design and development
 
Lecture7 web design and development
Lecture7 web design and developmentLecture7 web design and development
Lecture7 web design and development
 
Lecture6 web design and development
Lecture6 web design and developmentLecture6 web design and development
Lecture6 web design and development
 
Lecture5 web design and development
Lecture5 web design and developmentLecture5 web design and development
Lecture5 web design and development
 
Lecture4 web design and development
Lecture4 web design and developmentLecture4 web design and development
Lecture4 web design and development
 
Lecture3 web design and development
Lecture3 web design and developmentLecture3 web design and development
Lecture3 web design and development
 
Lecture2 web design and development
Lecture2 web design and developmentLecture2 web design and development
Lecture2 web design and development
 
Lecture1 Web Design and Development
Lecture1 Web Design and DevelopmentLecture1 Web Design and Development
Lecture1 Web Design and Development
 
Bootstrap day3
Bootstrap day3Bootstrap day3
Bootstrap day3
 
Bootstrap day1
Bootstrap day1Bootstrap day1
Bootstrap day1
 
Html_Day_One (W3Schools)
Html_Day_One (W3Schools)Html_Day_One (W3Schools)
Html_Day_One (W3Schools)
 
Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

CSS_Day_ONE (W3schools)

  • 1. www.afghanhost.af - info@afghanhost.af Instructor: Mohammad Rafi Haidari28-May-2014 CSS (Day 1)  What is CSS  CSS Syntax  Selectors  Ways to Insert CSS  Backgrounds
  • 2. CSS Introduction  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added to HTML 4.0 to solve a problem  External Style Sheets can save a lot of work  External Style Sheets are stored in CSS files CSS Saves a Lot of Work! CSS defines HOW HTML elements are to be displayed. Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!
  • 3. CSS Syntax  A CSS rule set consists of a selector and a declaration block:  The selector points to the HTML element you want to style.  The declaration block contains one or more declarations separated by semicolons.  Each declaration includes a property name and a value, separated by a colon.
  • 4. CSS Selectors  CSS selectors allow you to select and manipulate HTML element(s).  CSS selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, values of attributes and much more. The element Selector The element selector selects elements based on the element name. You can select all <p> elements on a page like this: (all <p> elements will be center-aligned, with a red text color) p { text-align:center;
  • 5. CSS Selectors The id Selector The id selector uses the id attribute of an HTML tag to find the specific element. An id should be unique within a page, so you should use the id selector when you want to find a single, unique element. To find an element with a specific id, write a hash character, followed by the id of the element. The style rule below will be applied to the HTML element with id="para1": #para1 { text-align:center; color:red; }
  • 6. CSS Selectors The class Selector The class selector finds elements with the specific class. The class selector uses the HTML class attribute. To find elements with a specific class, write a period character, followed by the name of the class: In the example below, all HTML elements with class="center" will be center-aligned: .center { text-align:center; color:red; }
  • 7. CSS Selectors 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: p.center { text-align:center; color:red; } Note: Do NOT start a class name with a number!
  • 8. CSS Selectors  Grouping Selectors  In style sheets there are often elements with the same style: h1 { text-align:center; color:red; } h2 { text-align:center; color:red; } p { text-align:center; color:red; } To minimize the code, you can group selectors. To group selectors, separate each selector with a comma. In the example below we have grouped the selectors from the code leftside: h1,h2,p { text-align:center; color:red;
  • 9. Ways to Insert CSS There are three ways of inserting a style sheet:  External style sheet  Internal style sheet  Inline style External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section: <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head>
  • 10. Ways to Insert CSS Note: An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below: hr {color:blue;} p {margin-left:20px;} body {background-image:url("images/background.gif");} Note:Do not add a space between the property value and the unit (such as margin-left:20 px). The correct way is: margin-
  • 11. Ways to Insert CSS Internal Style Sheet An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, by using the <style> tag, like this: <head> <style> hr {color:blue;} p {margin-left:20px;} body {background-image:url("images/background.gif");} </style> </head>
  • 12. Ways to Insert CSS Inline Styles An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly! To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph: <p style="color:blue;margin-left:20px;">This is a paragraph.</p>
  • 13. CSS Background CSS background properties are used to define the background effects of an element. CSS properties used for background effects:  background-color  background-image  background-repeat  background-position
  • 14. CSS Background Background Color The background-color property specifies the background color of an element. The background color of a page is defined in the body selector: body {background-color:#b0c4de;} 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:
  • 15. CSS Background 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, like this: body { background-image:url("gradient.png"); } If the image is repeated only horizontally (repeat-x), the background will look better: body { background-image:url("gradient.png"); background-repeat:repeat-x;
  • 16. CSS Background Set position and no-repeat The position of the image is specified by the background-position property: body { background-image:url("img_tree.png"); background-repeat:no-repeat; background-position:right top; } Property Values • left top • left center • left bottom • right top • right center • right bottom • center top • center center • center bottom