SlideShare a Scribd company logo
Introduction to CSS
CSS Defined: Short for "Cascading Style Sheets". Determines how the elements in our XHTML documents are displayed and formatted. Designed to separate the  content  of a web page from the  presentation  of that content. Enables us to make all pages of our website look similar and consistent (font, color, etc.). Allows us to make site-wide formatting changes from a single location (rather than having to edit each page individually).
Three Ways to Use CSS: Inline Style - CSS is placed directly into the XHTML element. Internal Style Sheet - CSS is placed into a separate area within the <head> section of a web page. External Style Sheet - CSS is placed into a separate computer file and &quot;connected&quot; to a web page.
CSS Format Conflicts: It's possible for CSS formatting to be defined in all three locations at the same time.  For example, a paragraph element could contain an inline style (color:red) but the internal style sheet (color:blue) and the external style sheet (color:green) give conflicting instructions to the web browser. Web browsers need a consistent way of &quot;settling&quot; this disagreement.
What is Meant by &quot;Cascading&quot;? We use the term cascading because there is an established order of priority to resolve these formatting conflicts: Inline style (highest priority) Internal style sheet (second priority) External style sheet (third priority) Web browser default (only if not defined elsewhere) For each XHTML element, the browser will check to see which inline styles are defined, then those styles in the internal style sheet, and finally those styles in the external sheet.  For all conflicts, it will use this priority system to determine which format to display on the page. In the prior example, the paragraph would display as red, because the inline style &quot;outranks&quot; all the others.
Example: Inline Style <h2  style=&quot;font-family:georgia; color:red;&quot; > CAUTION: Stormy Weather! </h2> An inline style declaration like this one will affect  only that particular element .  In other words, other <h2> elements on the page will not be affected by this formatting. A semicolon must follow each style declaration. Because inline styles do not properly separate content and presentation, their use is discouraged.  We will not be using inline styles in this class. PREVIEW:
Example: Internal Style Sheet <head> <style type=&quot;text/css&quot;> h2 {font-family:georgia; color:red;} </style> </head> Styles declared in the internal style sheet will affect  all matching elements on the page .  In this example, all <h2> elements on the page will be displayed in Georgia font and in red color. For internal style sheets, all formatting declarations are placed inside the <style> element within the <head> section of the document.  An element is listed and all the styling information follows, surrounded by opening and closing curly brackets,  { } . A semicolon must still follow each style declaration.
Example: External Style Sheet <head> <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; /> </head> Styles declared in an external style sheet will affect  all matching elements on all web pages that link to the stylesheet .  In this example, all <h2> elements on all pages using this style sheet will be displayed in Georgia font and in red color. For external style sheets, a <link> tag is placed at the beginning of the <head> section of the document specifying the external style sheet (with a .css extension) to be used for formatting.  The external style sheet uses the same syntax as the internal style sheet when listing elements and their styling. h2 {font-family:georgia; color:red;} style.css (separate file):
Internal vs. External Style Sheets Internal style sheets are appropriate for very small sites, especially those that have just one page. Internal style sheets might also make sense when each page of a site needs to have a completely different look. External style sheets are better for multi-page websites that need to have a uniform look and feel to all pages. External style sheets not only make for faster-loading sites (less redundant code) but also allow designers to make site-wide changes quickly and easily.
CSS Terminology and Syntax: p  {color:red;} Correct syntax: selector {property:value;} Selector Property Value Be careful to put the semicolon after each declaration.  It is the single most common mistake made by those learning CSS.
Setting Multiple Properties: p {  color:red;  font-style:italic; text-align:center; } Many designers choose to place the selector and the open bracket on a dedicated line and the closing bracket on its own line too.  By doing this, all the selectors in between are aligned and easy to read. You can define as many selectors as you wish for the element you are formatting. In the above example, all paragraph elements will now show red italic text that is centered on the page.
Setting a Background with CSS: body { background-image:url('picture.gif'); background-repeat:repeat-x; background-color:red; } With background-image, you can specify an image to be placed in the background of your web page. If you specify a background image, you can also decide whether the image will &quot;tile&quot; across or down the screen.  Possible values for the background-repeat property include repeat-x (horizontally only), repeat-y (vertical only), and no-repeat (no tiling at all).  If you don't specify this property at all, by default the image will repeat up and down to fill the entire page. You can use the background-color property to set one solid color for the background.  Even if you specify a background image, it is good practice to specify a color too.  If for some reason the background image is not available, the background color will be shown instead.
CSS Text Properties: The following properties can be specified for any element that contains text, such as <h1> thru <h6>, <p>, <ol>, <ul>, and <a>: Property Some Possible Values text-align:  center, left, right, justify text-decoration: underline, line-through, blink color: blue, green, yellow, red, white, etc. font-family: Arial, Verdana, &quot;Times New Roman&quot; font-size: large, 120%, 20px (pixels)    font-weight: bold, normal font-style: italic, normal For a full list of available color names, refer to the following page: http://www.w3.org/TR/css3-color/#svg-color

More Related Content

What's hot (20)

ODP
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
PPT
Cascading Style Sheet
vijayta
 
PPT
Css Ppt
Hema Prasanth
 
PPT
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
PPTX
What is CSS?
HalaiHansaika
 
PPTX
Css mod1
VARSHAKUMARI49
 
PPTX
Customizing the Appearance and HTML Output of Visualforce Pages
Mohammed Safwat Abu Kwaik
 
PPTX
Creating a webpage in html
Shrey Goswami
 
PPT
CSS ppt
Sanmuga Nathan
 
PPT
CSS
Gouthaman V
 
PPTX
Cascading style sheet
Michael Jhon
 
DOC
Css introduction
vishnu murthy
 
PPT
Introduction to Cascading Style Sheets
Tushar Joshi
 
PPTX
How to create a html webpage using notepad
SophieBarwick1999
 
PPTX
Css types internal, external and inline (1)
Webtech Learning
 
PPT
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
PPTX
CSS - LinkedIn
Gino Louie Peña, ITIL®,MOS®
 
PPT
Basics Of Css And Some Common Mistakes
sanjay2211
 
PPTX
Css Basics
Jay Patel
 
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
Cascading Style Sheet
vijayta
 
Css Ppt
Hema Prasanth
 
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
What is CSS?
HalaiHansaika
 
Css mod1
VARSHAKUMARI49
 
Customizing the Appearance and HTML Output of Visualforce Pages
Mohammed Safwat Abu Kwaik
 
Creating a webpage in html
Shrey Goswami
 
Cascading style sheet
Michael Jhon
 
Css introduction
vishnu murthy
 
Introduction to Cascading Style Sheets
Tushar Joshi
 
How to create a html webpage using notepad
SophieBarwick1999
 
Css types internal, external and inline (1)
Webtech Learning
 
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
Basics Of Css And Some Common Mistakes
sanjay2211
 
Css Basics
Jay Patel
 

Viewers also liked (20)

PDF
Introduction 2 css
Md Tarik Mahmud
 
PPTX
Komonvelt portoriko
Jelena Carević
 
PPTX
Špoģi-Syke
Eva Vovka
 
PPT
7.1 xhtml validation
Bulldogs83
 
PPTX
[Gmic]nale be cubbying
Hyoin Sung
 
PPTX
Presentation 10
rfvbgt111
 
PPT
6.1 special characters
Bulldogs83
 
PPTX
Ultimate frisbee
Mihajlo Gajic
 
PPS
Osnove windows-a
Mihajlo Gajic
 
PPTX
Java ders2
Murad İmanbayli
 
PPTX
Another world (1) The author Ilze
Eva Vovka
 
PPTX
Dress from newspapers_-_copy (1)
Eva Vovka
 
PPTX
Global dimension in social sciences subjects in formal
Eva Vovka
 
PPT
3.2 introduction to css
Bulldogs83
 
PPT
2.1 adding images
Bulldogs83
 
PDF
American Campaign to supress Islam
Abu Talha
 
PPTX
Marathon Oil Corp. Industry Profile
LIS7205
 
DOCX
Fstpt 15-solo-english
a_agung_kartika
 
PPT
Questionaire all-teachers-2011
Mihajlo Gajic
 
PPT
Geo gebra u1
Mihajlo Gajic
 
Introduction 2 css
Md Tarik Mahmud
 
Komonvelt portoriko
Jelena Carević
 
Špoģi-Syke
Eva Vovka
 
7.1 xhtml validation
Bulldogs83
 
[Gmic]nale be cubbying
Hyoin Sung
 
Presentation 10
rfvbgt111
 
6.1 special characters
Bulldogs83
 
Ultimate frisbee
Mihajlo Gajic
 
Osnove windows-a
Mihajlo Gajic
 
Java ders2
Murad İmanbayli
 
Another world (1) The author Ilze
Eva Vovka
 
Dress from newspapers_-_copy (1)
Eva Vovka
 
Global dimension in social sciences subjects in formal
Eva Vovka
 
3.2 introduction to css
Bulldogs83
 
2.1 adding images
Bulldogs83
 
American Campaign to supress Islam
Abu Talha
 
Marathon Oil Corp. Industry Profile
LIS7205
 
Fstpt 15-solo-english
a_agung_kartika
 
Questionaire all-teachers-2011
Mihajlo Gajic
 
Geo gebra u1
Mihajlo Gajic
 
Ad

Similar to 3.2 introduction to css (20)

PPTX
HTML to CSS Basics Exer 2.pptx
JJFajardo1
 
PPT
AK css
gauravashq
 
PPT
Week3 css
Rowena LI
 
PPT
CSS Part I
Doncho Minkov
 
PPT
How Style Sheets Work
Mark Carter
 
PPT
Lecture 5
uccwebcourses
 
PPT
CSS 101
dunclair
 
PPTX
CSS Basics (Cascading Style Sheet)
Ajay Khatri
 
PDF
Introduction to css
Joseph Gabriel
 
PDF
CSCADING style sheet. Internal external inline
Ranjeet Reddy
 
PDF
css-ppt.pdf
EktaDesai14
 
PPT
ch04-css-basics_final.ppt
GmachImen
 
PDF
Full
sanjaykhan33
 
PDF
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
hinalsomani93
 
HTML to CSS Basics Exer 2.pptx
JJFajardo1
 
AK css
gauravashq
 
Week3 css
Rowena LI
 
CSS Part I
Doncho Minkov
 
How Style Sheets Work
Mark Carter
 
Lecture 5
uccwebcourses
 
CSS 101
dunclair
 
CSS Basics (Cascading Style Sheet)
Ajay Khatri
 
Introduction to css
Joseph Gabriel
 
CSCADING style sheet. Internal external inline
Ranjeet Reddy
 
css-ppt.pdf
EktaDesai14
 
ch04-css-basics_final.ppt
GmachImen
 
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
hinalsomani93
 
Ad

More from Bulldogs83 (15)

PPT
7.2 external style sheets
Bulldogs83
 
PPT
6.2 css link styling
Bulldogs83
 
PPT
5.2 nesting and floating elements
Bulldogs83
 
PPT
5.1 css box model
Bulldogs83
 
PPT
4.3 table styling
Bulldogs83
 
PPT
4.2 css classes
Bulldogs83
 
PPT
4.1 advanced tables
Bulldogs83
 
PPT
3.1 xhtml tables
Bulldogs83
 
PPT
1.4 adding comments copy (2)
Bulldogs83
 
PPT
1.4 adding comments copy (2)
Bulldogs83
 
PPT
1.3 creating links
Bulldogs83
 
PPT
1.3 creating links
Bulldogs83
 
PPT
1.2 elements and attributes copy (3)
Bulldogs83
 
PPT
1.2 elements and attributes copy (3)
Bulldogs83
 
PPT
1.1 xhtml basics
Bulldogs83
 
7.2 external style sheets
Bulldogs83
 
6.2 css link styling
Bulldogs83
 
5.2 nesting and floating elements
Bulldogs83
 
5.1 css box model
Bulldogs83
 
4.3 table styling
Bulldogs83
 
4.2 css classes
Bulldogs83
 
4.1 advanced tables
Bulldogs83
 
3.1 xhtml tables
Bulldogs83
 
1.4 adding comments copy (2)
Bulldogs83
 
1.4 adding comments copy (2)
Bulldogs83
 
1.3 creating links
Bulldogs83
 
1.3 creating links
Bulldogs83
 
1.2 elements and attributes copy (3)
Bulldogs83
 
1.2 elements and attributes copy (3)
Bulldogs83
 
1.1 xhtml basics
Bulldogs83
 

Recently uploaded (20)

PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 

3.2 introduction to css

  • 2. CSS Defined: Short for &quot;Cascading Style Sheets&quot;. Determines how the elements in our XHTML documents are displayed and formatted. Designed to separate the content of a web page from the presentation of that content. Enables us to make all pages of our website look similar and consistent (font, color, etc.). Allows us to make site-wide formatting changes from a single location (rather than having to edit each page individually).
  • 3. Three Ways to Use CSS: Inline Style - CSS is placed directly into the XHTML element. Internal Style Sheet - CSS is placed into a separate area within the <head> section of a web page. External Style Sheet - CSS is placed into a separate computer file and &quot;connected&quot; to a web page.
  • 4. CSS Format Conflicts: It's possible for CSS formatting to be defined in all three locations at the same time. For example, a paragraph element could contain an inline style (color:red) but the internal style sheet (color:blue) and the external style sheet (color:green) give conflicting instructions to the web browser. Web browsers need a consistent way of &quot;settling&quot; this disagreement.
  • 5. What is Meant by &quot;Cascading&quot;? We use the term cascading because there is an established order of priority to resolve these formatting conflicts: Inline style (highest priority) Internal style sheet (second priority) External style sheet (third priority) Web browser default (only if not defined elsewhere) For each XHTML element, the browser will check to see which inline styles are defined, then those styles in the internal style sheet, and finally those styles in the external sheet. For all conflicts, it will use this priority system to determine which format to display on the page. In the prior example, the paragraph would display as red, because the inline style &quot;outranks&quot; all the others.
  • 6. Example: Inline Style <h2 style=&quot;font-family:georgia; color:red;&quot; > CAUTION: Stormy Weather! </h2> An inline style declaration like this one will affect only that particular element . In other words, other <h2> elements on the page will not be affected by this formatting. A semicolon must follow each style declaration. Because inline styles do not properly separate content and presentation, their use is discouraged. We will not be using inline styles in this class. PREVIEW:
  • 7. Example: Internal Style Sheet <head> <style type=&quot;text/css&quot;> h2 {font-family:georgia; color:red;} </style> </head> Styles declared in the internal style sheet will affect all matching elements on the page . In this example, all <h2> elements on the page will be displayed in Georgia font and in red color. For internal style sheets, all formatting declarations are placed inside the <style> element within the <head> section of the document. An element is listed and all the styling information follows, surrounded by opening and closing curly brackets, { } . A semicolon must still follow each style declaration.
  • 8. Example: External Style Sheet <head> <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; /> </head> Styles declared in an external style sheet will affect all matching elements on all web pages that link to the stylesheet . In this example, all <h2> elements on all pages using this style sheet will be displayed in Georgia font and in red color. For external style sheets, a <link> tag is placed at the beginning of the <head> section of the document specifying the external style sheet (with a .css extension) to be used for formatting. The external style sheet uses the same syntax as the internal style sheet when listing elements and their styling. h2 {font-family:georgia; color:red;} style.css (separate file):
  • 9. Internal vs. External Style Sheets Internal style sheets are appropriate for very small sites, especially those that have just one page. Internal style sheets might also make sense when each page of a site needs to have a completely different look. External style sheets are better for multi-page websites that need to have a uniform look and feel to all pages. External style sheets not only make for faster-loading sites (less redundant code) but also allow designers to make site-wide changes quickly and easily.
  • 10. CSS Terminology and Syntax: p {color:red;} Correct syntax: selector {property:value;} Selector Property Value Be careful to put the semicolon after each declaration. It is the single most common mistake made by those learning CSS.
  • 11. Setting Multiple Properties: p { color:red; font-style:italic; text-align:center; } Many designers choose to place the selector and the open bracket on a dedicated line and the closing bracket on its own line too. By doing this, all the selectors in between are aligned and easy to read. You can define as many selectors as you wish for the element you are formatting. In the above example, all paragraph elements will now show red italic text that is centered on the page.
  • 12. Setting a Background with CSS: body { background-image:url('picture.gif'); background-repeat:repeat-x; background-color:red; } With background-image, you can specify an image to be placed in the background of your web page. If you specify a background image, you can also decide whether the image will &quot;tile&quot; across or down the screen. Possible values for the background-repeat property include repeat-x (horizontally only), repeat-y (vertical only), and no-repeat (no tiling at all). If you don't specify this property at all, by default the image will repeat up and down to fill the entire page. You can use the background-color property to set one solid color for the background. Even if you specify a background image, it is good practice to specify a color too. If for some reason the background image is not available, the background color will be shown instead.
  • 13. CSS Text Properties: The following properties can be specified for any element that contains text, such as <h1> thru <h6>, <p>, <ol>, <ul>, and <a>: Property Some Possible Values text-align: center, left, right, justify text-decoration: underline, line-through, blink color: blue, green, yellow, red, white, etc. font-family: Arial, Verdana, &quot;Times New Roman&quot; font-size: large, 120%, 20px (pixels) font-weight: bold, normal font-style: italic, normal For a full list of available color names, refer to the following page: http://www.w3.org/TR/css3-color/#svg-color