SlideShare a Scribd company logo
1 of 24
Download to read offline
Basic CSS

  Author: Dwight VanTuyl
Created: September 29, 2008
     The LINGUIST List
What is CSS?
• Cascading: Multiple styles can overlap in order
  to specify a range of style from a whole web site
  down to a unique element. Which style gets
  applied pertains to the rules of CSS cascading
  logic.
• Style: CSS deals specifically with the
  presentation domain of designing a web page
  (color, font, layout, etc).
• Sheet: Normally, CSS is a file separate from the
  HTML file – linked to the HTML file through its
  <head> (exceptions apply).
Why CSS?
• Allows for much richer document appearances
  than HTML.
• Reduce workload by centralizing commands for
  visual appearance instead of scattered
  throughout the HTML doc.
• Use same style on multiple pages.
• Reduce page download size.

 Use HTML for content; CSS for Presentation.
Reference CSS from HTML
   <link rel=“stylesheet” type=“text/css” href=“lipstick.css” />




              pig.html                           lipstick.css
<html>
          <head>
          <link rel="stylesheet"
          type="text/css"
          href=“lipstick.css" />
          </head>
  …
</html>
CSS Syntax
     Selector                   Style Block

       h1          {
                       color: red;                          Style
 Element                                                    Values
 Properties            background: yellow;
                   }

•The Selector selects elements on the HTML page.
•The associated Style Block applies its Style Values to the selected
Element’s Properties
Selectors
• Select elements to apply a declared style.
• Selector types:
  – Element Selectors: selects all elements of a
    specific type (<body>, <h1>, <p>, etc.)
  – Class Selectors: selects all elements that
    belong to a given class.
  – ID Selectors: selects a single element that’s
    been given a unique id.
  – Pseudo Selectors: combines a selector with a
    user activated state (:hover, :link, :visited)
Element Selectors
• Finds all HTML elements that have the specified
  element type.
• Example:

                h1 {
                       color: blue;
                }

Finds all elements of type <h1> and makes the
  text color blue.
Class Selectors
• Finds all elements of a given class – based on the
  attribute’s class value.
• Syntax: .classname (Remember the dot means class
  selector)
• Example:

              .legs {
                  font-weight: bold;
                  background: pink;
              }

Finds all elements whose class = “legs” and makes their
   font bold and their backgrounds pink.
ID Selectors
• Finds a single element that’s been given a
  unique id – based on the attribute’s id value.
• Syntax: #idname (Remember the pound-sign
  means id selector)
• Example:

            #snout{
                border: solid red;
            }

Finds a single element whose id = “snout” and
  gives it a solid red border.
Pseudo-Selectors
• Apply styles to a user activated state of an
  element.
• If used, must be declared in a specific order in
  the style sheet.
• General Purpose Pseudo-Selector:
  – :hover      Element with mouse over
• Specific to hyperlinks (and/or buttons)
  – a:active     A link or button that is currently being
                     clicked on.
  – a:link       A link that has NOT been visited yet.
  – a:visited    A link that HAS been visited.
Grouping Selectors
• Lets say you want to apply the same style to several
  different selectors. Don’t repeat the style – use a
  comma!!
• Syntax: sel1, sel2, sel3 (Remember the comma to
  group several different selectors)
• Example:

               h1, .legs, #snout{
                   font-size: 20pt;
               }

Finds all elements of type <h1>, all elements with
   class=“legs” and the single element whose id = “snout”
   then makes their font-size 20pt.
Conflict Resolution
• It’s possible to have different styles
  applied to the same selector
  (CascadingSS), but what if the styles tell
  the browser to do conflicting things?
• Rules:
  – Which selector is more specific?
  – If the selectors are the same, then which style
    was applied last?
Sharpen Your Selector
• Order of specificity:
     (specific) id, class, element type (ambiguous)



• Combine selectors:
     Elementype.classname or Elementype#idname


     e.g.        p.legs        or       h2#snout
Sharpen Your Selector (cont.)
• Descendant Selectors:
     Specify the context in the HTML tree from each ancestor down to the
       desired element – each separated by a space.

     e.g.    body.pig     p.pig-head      #snout

• HTML Tree:
     <body class=“pig”>
           <p class=“pig-head”>
                  <h1 id=“snout”>
                        Snout Snout Snout
                  </h1>
           </p>
     </body>
Firebug – Firefox Addon
• Tool for figuring out what styles are being
  applied to which element (and which are being
  overwritten due to conflict resolution).

• http://getfirebug.com/

• Right-click on an element,
  then select “Inspect Element” from the dropdown
    menu.
<span> Element tag
• Useful for applying style to text within
  another HTML element.
• Use SPARINGLY – unlike <h1> or <p>,
  <span> has no semantic meaning.
• Remember, HTML is for content and
  HTML tags are for describing that content
  to non-human or visually-impaired
  readers. <span> is just used to make
  things “pretty.”
<div> Element tag
• Useful for dividing parts of the page into sections.
• Creates a “box” with the following attributes:
   –   margin
   –   padding
   –   border
   –   height
   –   width
   –   (..and lots more)


• Primary element used for CSS Layouts
  (more information in CSS Layouts tutorial)
Color Properties
• color: specifies the text color.
• background-color: specifies the background color.

            black; or #000000;
            red; or #FF0000;
            lime; or #00FF00;
            blue; or #0000FF;
            white; or #000000;

…and more see:
  http://www.w3schools.com/css/css_colornames.asp
Colorzilla – Firefox Addon
• Easily find color values for elements in a
  document.
• http://www.iosart.com/firefox/colorzilla/
• Click on the eyedropper icon in the
  bottom-left of the browser and select any
  color in your browser window.
• Right-click on the eyedropper for more
  options.
Background Image Properties
• background-image: url(../location/of/image.jpg)
• background-repeat: tile image in
  background
• background-position: vertical (top,
  center, bottom, or size) horizontal (left,
  center, right, or size)
• background-attachment: (scroll or fixed)
Font Properties
• font-family: times, arial, serif, sans-serif,
  monospace;
• font-style: italic;
• font-weight: (bold, bolder, lighter, or 100 – 900;)
• font-size: size;
  …or shorthand
• font: style weight size family;
Text Properties
• text-indent: indents first line of a
  paragraph according to size
• text-align: right; or left; or center; or
  justify;
• text-decoration: none; or underline;
• text-transform: Capitalize;
• Line-height: added vertical space to each
  line of text according to size
List Properties <ul>
• list-style-type: none, disc, circle, square,
  (other types available)
• list-style-position: inside or outside
• list-style-image: url(../path/to/image.jpg)

  …or shorthand
• list-style: type position image
Border Properties
• border-width: (thin, medium, thick, or size)
• border-style: (none, hidden, dotted, dashed,
  solid, double, groove, ridge, inset, or outset)
• border-color: color

  …or shorthand
• border(-top, -right, -left, -bottom): width style
  color

More Related Content

What's hot (20)

Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
 
Html and css
Html and cssHtml and css
Html and css
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
CSS - Text Properties
CSS - Text PropertiesCSS - Text Properties
CSS - Text Properties
 
Html
HtmlHtml
Html
 
Css position
Css positionCss position
Css position
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
CSS.ppt
CSS.pptCSS.ppt
CSS.ppt
 
CSS
CSSCSS
CSS
 
Html & CSS
Html & CSSHtml & CSS
Html & CSS
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Css3
Css3Css3
Css3
 
Html,javascript & css
Html,javascript & cssHtml,javascript & css
Html,javascript & css
 
CSS
CSS CSS
CSS
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 

Viewers also liked

candi-binding-tutorial
candi-binding-tutorialcandi-binding-tutorial
candi-binding-tutorialtutorialsruby
 
Jonny_Martin-Asterisk
Jonny_Martin-AsteriskJonny_Martin-Asterisk
Jonny_Martin-Asterisktutorialsruby
 
Cox(Feight)_Robert final_slideshow
Cox(Feight)_Robert final_slideshowCox(Feight)_Robert final_slideshow
Cox(Feight)_Robert final_slideshowRobert Feight
 
YaleChildStudy_Face_Morph_Tutorial_4-11-08
YaleChildStudy_Face_Morph_Tutorial_4-11-08YaleChildStudy_Face_Morph_Tutorial_4-11-08
YaleChildStudy_Face_Morph_Tutorial_4-11-08tutorialsruby
 
ЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХ
ЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХ
ЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХMeteor City
 
由Hash Set谈重用
由Hash Set谈重用由Hash Set谈重用
由Hash Set谈重用yiditushe
 
Passegiata A S.Lorenzello Nel Sannio
Passegiata A S.Lorenzello Nel SannioPassegiata A S.Lorenzello Nel Sannio
Passegiata A S.Lorenzello Nel SannioMy own sweet home
 
Transformers Episode 16 Omega Supreme
Transformers Episode 16 Omega SupremeTransformers Episode 16 Omega Supreme
Transformers Episode 16 Omega SupremeRyan Sadler
 
REFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICER
REFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICERREFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICER
REFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICERMaria Raju
 
CERT - GULF TRAINER - EXECUTIVE SECRETARY & PA
CERT - GULF TRAINER - EXECUTIVE SECRETARY & PACERT - GULF TRAINER - EXECUTIVE SECRETARY & PA
CERT - GULF TRAINER - EXECUTIVE SECRETARY & PAMaria Raju
 

Viewers also liked (20)

Ejb方面
Ejb方面Ejb方面
Ejb方面
 
lab4_php
lab4_phplab4_php
lab4_php
 
candi-binding-tutorial
candi-binding-tutorialcandi-binding-tutorial
candi-binding-tutorial
 
Born_ruby_on_rails
Born_ruby_on_railsBorn_ruby_on_rails
Born_ruby_on_rails
 
phptut4
phptut4phptut4
phptut4
 
Jonny_Martin-Asterisk
Jonny_Martin-AsteriskJonny_Martin-Asterisk
Jonny_Martin-Asterisk
 
mastercam_full
mastercam_fullmastercam_full
mastercam_full
 
Cox(Feight)_Robert final_slideshow
Cox(Feight)_Robert final_slideshowCox(Feight)_Robert final_slideshow
Cox(Feight)_Robert final_slideshow
 
YaleChildStudy_Face_Morph_Tutorial_4-11-08
YaleChildStudy_Face_Morph_Tutorial_4-11-08YaleChildStudy_Face_Morph_Tutorial_4-11-08
YaleChildStudy_Face_Morph_Tutorial_4-11-08
 
veracruz
veracruzveracruz
veracruz
 
phptutorial
phptutorialphptutorial
phptutorial
 
Tutorial5
Tutorial5Tutorial5
Tutorial5
 
ЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХ
ЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХ
ЖАНРООБРАЗУЮЩАЯ ФУНКЦИЯ ПРИЛАГАТЕЛЬНЫХ В ЗАГАДКАХ
 
由Hash Set谈重用
由Hash Set谈重用由Hash Set谈重用
由Hash Set谈重用
 
Passegiata A S.Lorenzello Nel Sannio
Passegiata A S.Lorenzello Nel SannioPassegiata A S.Lorenzello Nel Sannio
Passegiata A S.Lorenzello Nel Sannio
 
Transformers Episode 16 Omega Supreme
Transformers Episode 16 Omega SupremeTransformers Episode 16 Omega Supreme
Transformers Episode 16 Omega Supreme
 
40020
4002040020
40020
 
ARMY Education Transcript
ARMY Education TranscriptARMY Education Transcript
ARMY Education Transcript
 
REFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICER
REFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICERREFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICER
REFERENCE - MARITIME - PA. PRO.ADMIN & HR OFFICER
 
CERT - GULF TRAINER - EXECUTIVE SECRETARY & PA
CERT - GULF TRAINER - EXECUTIVE SECRETARY & PACERT - GULF TRAINER - EXECUTIVE SECRETARY & PA
CERT - GULF TRAINER - EXECUTIVE SECRETARY & PA
 

Similar to Basic-CSS-tutorial

Similar to Basic-CSS-tutorial (20)

Basic css
Basic cssBasic css
Basic css
 
Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
 
CSS
CSSCSS
CSS
 
Ifi7174 lesson2
Ifi7174 lesson2Ifi7174 lesson2
Ifi7174 lesson2
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
 
Understanding CSS for web development by software outsourcing company india
Understanding CSS for web development by software outsourcing company indiaUnderstanding CSS for web development by software outsourcing company india
Understanding CSS for web development by software outsourcing company india
 
Introduction 2 css
Introduction 2 cssIntroduction 2 css
Introduction 2 css
 
Css
CssCss
Css
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
 
CSS Introduction
CSS Introduction CSS Introduction
CSS Introduction
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
 
Css
CssCss
Css
 
CSS(Cascading Stylesheet)
CSS(Cascading Stylesheet)CSS(Cascading Stylesheet)
CSS(Cascading Stylesheet)
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
 
Css
CssCss
Css
 
Css
CssCss
Css
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By Mukesh
 

More from tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

More from tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Basic-CSS-tutorial

  • 1. Basic CSS Author: Dwight VanTuyl Created: September 29, 2008 The LINGUIST List
  • 2. What is CSS? • Cascading: Multiple styles can overlap in order to specify a range of style from a whole web site down to a unique element. Which style gets applied pertains to the rules of CSS cascading logic. • Style: CSS deals specifically with the presentation domain of designing a web page (color, font, layout, etc). • Sheet: Normally, CSS is a file separate from the HTML file – linked to the HTML file through its <head> (exceptions apply).
  • 3. Why CSS? • Allows for much richer document appearances than HTML. • Reduce workload by centralizing commands for visual appearance instead of scattered throughout the HTML doc. • Use same style on multiple pages. • Reduce page download size. Use HTML for content; CSS for Presentation.
  • 4. Reference CSS from HTML <link rel=“stylesheet” type=“text/css” href=“lipstick.css” /> pig.html lipstick.css <html> <head> <link rel="stylesheet" type="text/css" href=“lipstick.css" /> </head> … </html>
  • 5. CSS Syntax Selector Style Block h1 { color: red; Style Element Values Properties background: yellow; } •The Selector selects elements on the HTML page. •The associated Style Block applies its Style Values to the selected Element’s Properties
  • 6. Selectors • Select elements to apply a declared style. • Selector types: – Element Selectors: selects all elements of a specific type (<body>, <h1>, <p>, etc.) – Class Selectors: selects all elements that belong to a given class. – ID Selectors: selects a single element that’s been given a unique id. – Pseudo Selectors: combines a selector with a user activated state (:hover, :link, :visited)
  • 7. Element Selectors • Finds all HTML elements that have the specified element type. • Example: h1 { color: blue; } Finds all elements of type <h1> and makes the text color blue.
  • 8. Class Selectors • Finds all elements of a given class – based on the attribute’s class value. • Syntax: .classname (Remember the dot means class selector) • Example: .legs { font-weight: bold; background: pink; } Finds all elements whose class = “legs” and makes their font bold and their backgrounds pink.
  • 9. ID Selectors • Finds a single element that’s been given a unique id – based on the attribute’s id value. • Syntax: #idname (Remember the pound-sign means id selector) • Example: #snout{ border: solid red; } Finds a single element whose id = “snout” and gives it a solid red border.
  • 10. Pseudo-Selectors • Apply styles to a user activated state of an element. • If used, must be declared in a specific order in the style sheet. • General Purpose Pseudo-Selector: – :hover Element with mouse over • Specific to hyperlinks (and/or buttons) – a:active A link or button that is currently being clicked on. – a:link A link that has NOT been visited yet. – a:visited A link that HAS been visited.
  • 11. Grouping Selectors • Lets say you want to apply the same style to several different selectors. Don’t repeat the style – use a comma!! • Syntax: sel1, sel2, sel3 (Remember the comma to group several different selectors) • Example: h1, .legs, #snout{ font-size: 20pt; } Finds all elements of type <h1>, all elements with class=“legs” and the single element whose id = “snout” then makes their font-size 20pt.
  • 12. Conflict Resolution • It’s possible to have different styles applied to the same selector (CascadingSS), but what if the styles tell the browser to do conflicting things? • Rules: – Which selector is more specific? – If the selectors are the same, then which style was applied last?
  • 13. Sharpen Your Selector • Order of specificity: (specific) id, class, element type (ambiguous) • Combine selectors: Elementype.classname or Elementype#idname e.g. p.legs or h2#snout
  • 14. Sharpen Your Selector (cont.) • Descendant Selectors: Specify the context in the HTML tree from each ancestor down to the desired element – each separated by a space. e.g. body.pig p.pig-head #snout • HTML Tree: <body class=“pig”> <p class=“pig-head”> <h1 id=“snout”> Snout Snout Snout </h1> </p> </body>
  • 15. Firebug – Firefox Addon • Tool for figuring out what styles are being applied to which element (and which are being overwritten due to conflict resolution). • http://getfirebug.com/ • Right-click on an element, then select “Inspect Element” from the dropdown menu.
  • 16. <span> Element tag • Useful for applying style to text within another HTML element. • Use SPARINGLY – unlike <h1> or <p>, <span> has no semantic meaning. • Remember, HTML is for content and HTML tags are for describing that content to non-human or visually-impaired readers. <span> is just used to make things “pretty.”
  • 17. <div> Element tag • Useful for dividing parts of the page into sections. • Creates a “box” with the following attributes: – margin – padding – border – height – width – (..and lots more) • Primary element used for CSS Layouts (more information in CSS Layouts tutorial)
  • 18. Color Properties • color: specifies the text color. • background-color: specifies the background color. black; or #000000; red; or #FF0000; lime; or #00FF00; blue; or #0000FF; white; or #000000; …and more see: http://www.w3schools.com/css/css_colornames.asp
  • 19. Colorzilla – Firefox Addon • Easily find color values for elements in a document. • http://www.iosart.com/firefox/colorzilla/ • Click on the eyedropper icon in the bottom-left of the browser and select any color in your browser window. • Right-click on the eyedropper for more options.
  • 20. Background Image Properties • background-image: url(../location/of/image.jpg) • background-repeat: tile image in background • background-position: vertical (top, center, bottom, or size) horizontal (left, center, right, or size) • background-attachment: (scroll or fixed)
  • 21. Font Properties • font-family: times, arial, serif, sans-serif, monospace; • font-style: italic; • font-weight: (bold, bolder, lighter, or 100 – 900;) • font-size: size; …or shorthand • font: style weight size family;
  • 22. Text Properties • text-indent: indents first line of a paragraph according to size • text-align: right; or left; or center; or justify; • text-decoration: none; or underline; • text-transform: Capitalize; • Line-height: added vertical space to each line of text according to size
  • 23. List Properties <ul> • list-style-type: none, disc, circle, square, (other types available) • list-style-position: inside or outside • list-style-image: url(../path/to/image.jpg) …or shorthand • list-style: type position image
  • 24. Border Properties • border-width: (thin, medium, thick, or size) • border-style: (none, hidden, dotted, dashed, solid, double, groove, ridge, inset, or outset) • border-color: color …or shorthand • border(-top, -right, -left, -bottom): width style color