SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
CSS
Cascading Style Sheets
Parts of a CSS rule


h2 {
color: #000000;
}
Parts of a CSS rule


h2 {
color: #000000;
}
        SELECTOR
Parts of a CSS rule


h2 {
color: #000000;
}
     CURLY BRACKETS
Parts of a CSS rule


h2 {
color: #000000;
}
        PROPERTY
Parts of a CSS rule


h2 {
color: #000000;
}
         VALUE
Parts of a CSS rule


h2 {
color: #000000;
}
   START WITH SELECTOR
Three Kinds of Selectors
TYPE SELECTORS   CLASS SELECTORS   ID SELECTORS

div              .headlines        #container
p                .paragraphs       #first-­‐article
h2               .bylines          #footer
strong           .summary          #sidebar
Type Selectors
                               <body>
h2 {                            <div id=“container”>

                                  <h2 class=“headline”>Hello World</h2>
    font-style: bold;
                                  <p class=“byline”>By Jeremy Rue.</p>
}
                                  <p>In todayʼs news, a class at UC Berkeley
                                  learned the importance of CSS in designing
                                  and building webpages.</p>

p{                                <div id=“sidebar”>
                                    <h2>Side Bar Story</h2>
                                    <p class=“byline”>By John Doe.</p>
    font-family: Helvetica;         <p>This is a related story.</p>
                                  </div>
}
                                 </div>
                               </body>
Type Selectors
                               <body>
h2 {                            <div id=“container”>

                                  <h2 class=“headline”>Hello World</h2>
    font-style: bold;
                                  <p class=“byline”>By Jeremy Rue.</p>
}
                                  <p>In todayʼs news, a class at UC Berkeley
                                  learned the importance of CSS in designing
                                  and building webpages.</p>

p{                                <div id=“sidebar”>
                                    <h2>Side Bar Story</h2>
                                    <p class=“byline”>By John Doe.</p>
    font-family: Helvetica;         <p>This is a related story.</p>
                                  </div>
}
                                 </div>
                               </body>
Class Selectors
                                  <body>
.headline {                        <div id=“container”>

                                     <h2 class=“headline”>Hello World</h2>
    text-decoration: underline;
                                     <p class=“byline”>By Jeremy Rue.</p>
}
                                     <p>In todayʼs news, a class at UC Berkeley
                                     learned the importance of CSS in designing
                                     and building webpages.</p>

.byline {                            <div id=“sidebar”>
                                       <h2>Side Bar Story</h2>
                                       <p class=“byline”>By John Doe.</p>
    font-size: 8px;                    <p>This is a related story.</p>
                                     </div>
}
                                    </div>
                                  </body>
Class Selectors
                                  <body>
.headline {                        <div id=“container”>

                                     <h2 class=“headline”>Hello World</h2>
    text-decoration: underline;
                                     <p class=“byline”>By Jeremy Rue.</p>
}
                                     <p>In todayʼs news, a class at UC Berkeley
                                     learned the importance of CSS in designing
                                     and building webpages.</p>

.byline {                            <div id=“sidebar”>
                                       <h2>Side Bar Story</h2>
                                       <p class=“byline”>By John Doe.</p>
    font-size: 8px;                    <p>This is a related story.</p>
                                     </div>
}
                                    </div>
                                  </body>
ID Selectors
                             <body>
#container {                  <div id=“container”>

                                <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                                <p class=“byline”>By Jeremy Rue.</p>
}
                                <p>In todayʼs news, a class at UC Berkeley
                                learned the importance of CSS in designing
                                and building webpages.</p>

#sidebar {                      <div id=“sidebar”>
                                  <h2>Side Bar Story</h2>
                                  <p class=“byline”>By John Doe.</p>
    font-size: 8px;               <p>This is a related story.</p>
                                </div>
}
                               </div>
                             </body>
ID Selectors
                             <body>
#container {                  <div id=“container”>

                                <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                                <p class=“byline”>By Jeremy Rue.</p>
}
                                <p>In todayʼs news, a class at UC Berkeley
                                learned the importance of CSS in designing
                                and building webpages.</p>

#sidebar {                      <div id=“sidebar”>
                                  <h2>Side Bar Story</h2>
                                  <p class=“byline”>By John Doe.</p>
    font-size: 8px;               <p>This is a related story.</p>
                                </div>
}
                               </div>
                             </body>
More ways to use selectors
More Selector Options
                          <body>
.headline{                 <div id=“container”>

                             <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                             <p class=“byline”>By Jeremy Rue.</p>
}
                             <p>In todayʼs news, a class at UC Berkeley
                             learned the importance of CSS in designing
                             and building webpages.</p>

                             <div id=“sidebar”>
                               <h3 class=“headline”>Side Bar Story</h3>
                               <p class=“byline”>By John Doe.</p>
                               <p>This is a related story.</p>
                             </div>

                            </div>
                          </body>
More Selector Options
                          <body>
h2.headline {              <div id=“container”>

                             <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                             <p class=“byline”>By Jeremy Rue.</p>
}
                             <p>In todayʼs news, a class at UC Berkeley
                             learned the importance of CSS in designing
                             and building webpages.</p>

                             <div id=“sidebar”>
                               <h3 class=“headline”>Side Bar Story</h3>
                               <p class=“byline”>By John Doe.</p>
                               <p>This is a related story.</p>
                             </div>

                            </div>
                          </body>
More Selector Options
                          <body>
#sidebar p {               <div id=“container”>

                             <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                             <p class=“byline”>By Jeremy Rue.</p>
}
                             <p>In todayʼs news, a class at UC Berkeley
                             learned the importance of CSS in designing
                             and building webpages.</p>

A space means                <div id=“sidebar”>
descendant.                    <h3 class=“headline”>Side Bar Story</h3>
                               <p class=“byline”>By John Doe.</p>
                               <p>This is a related story.</p>
                             </div>

                            </div>
                          </body>
More Selector Options
                           <body>
#container #sidebar h3 {    <div id=“container”>

                              <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                              <p class=“byline”>By Jeremy Rue.</p>
}
                              <p>In todayʼs news, a class at UC Berkeley
                              learned the importance of CSS in designing
                              and building webpages.</p>

                              <div id=“sidebar”>
                                <h3 class=“headline”>Side Bar Story</h3>
                                <p class=“byline”>By John Doe.</p>
                                <p>This is a related story.</p>
                              </div>

                             </div>
                           </body>
More Selector Options
                           <body>
#container #sidebar h3 {    <div id=“container”>

                              <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                              <p class=“byline”>By Jeremy Rue.</p>
}
                              <p>In todayʼs news, a class at UC Berkeley
                              learned the importance of CSS in designing
                              and building webpages.</p>

                              <div id=“sidebar”>
                                <h3 class=“headline”>Side Bar Story</h3>
                                <p class=“byline”>By John Doe.</p>
                                <p>This is a related story.</p>
                              </div>

                             </div>
                           </body>
More Selector Options
                           <body>
#container #sidebar h3 {    <div id=“container”>

                              <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                              <p class=“byline”>By Jeremy Rue.</p>
}
                              <p>In todayʼs news, a class at UC Berkeley
                              learned the importance of CSS in designing
                              and building webpages.</p>

                              <div id=“sidebar”>
                                <h3 class=“headline”>Side Bar Story</h3>
                                <p class=“byline”>By John Doe.</p>
                                <p>This is a related story.</p>
                              </div>

                             </div>
                           </body>
More Selector Options
                           <body>
#container #sidebar h3 {    <div id=“container”>

                              <h2 class=“headline”>Hello World</h2>
    font-size: 30px;
                              <p class=“byline”>By Jeremy Rue.</p>
}
                              <p>In todayʼs news, a class at UC Berkeley
                              learned the importance of CSS in designing
                              and building webpages.</p>

                              <div id=“sidebar”>
                                <h3 class=“headline”>Side Bar Story</h3>
                                <p class=“byline”>By John Doe.</p>
                                <p>This is a related story.</p>
                              </div>

                             </div>
                           </body>
NOT to be confused with...
HTML vs CSS
               HTML                                          CSS

<div class=“headline lead-story article”>                .headline p {

                                                         }

              These spaces give multiple classes   This space means a <p> tag inside
                                                    another tag with class .headline
Example from Richmond Site


<div id="post-38661" class="hentry p1 post publish author-lexi-
pandell category-education category-featured category-front
tag-big-brother-big-sister tag-mentoring tag-nonprofit tag-
youth y2012 m02 d07 h13">
A few others
                                 <div id=“container”>
h3, p { color:orange; }
                                  <h3>Here is one headline</h3>

                                  <div>
                                   <h3>Another</h3>
                                   <p>Some text here</p>
                                  </div>

                                  <p>Another paragraph.</p>
                                  <h3>Last graph.</h3>

                                 </div>
A few others
                                    <div id=“container”>
#container > h3 { color:orange; }
                                     <h3>Here is one headline</h3>

                                     <div>
                                      <h3>Another</h3>
                                      <p>Some text here</p>
                                     </div>

                                     <p>Another paragraph.</p>
                                     <h3>Last graph.</h3>

                                    </div>
A few others
                              <div id=“container”>
h3 + p { color:orange; }
                               <h3>Here is one headline</h3>

                               <div>
                                <h3>Another</h3>
                                <p>Some text here</p>
                               </div>

                               <p>Another paragraph.</p>
                               <h3>Last graph.</h3>

                              </div>
A few others
                                  <div id=“container”>
h3:first-child { color:orange; }
                                   <h3>Here is one headline</h3>

                                   <div>
                                    <h3>Another</h3>
                                    <p>Some text here</p>
                                   </div>

                                   <p>Another paragraph.</p>
                                   <h3>Last graph.</h3>

                                  </div>
The Cascade
What happens if there is a conflict?
External Style Sheet    Embedded Style Sheet           Inline Styles

                            <head>
                             <style>

                               .headlines {
                                                <div style= “color:black;”>
                                 color:black;
                               }

                              </style>
                            </head>




                The more specific rules take precedence.
Which rule wins out?
#container {                 <div id="container">

    font-size: 30px;          <div id="headline">
}                              <p>My headline</p>
#headline {
                              </div>
    font-size: 10px;
                             </div>
}
Which rule wins out?
#container {                               <div id="container">

    font-size: 30px;                           <div id="headline">
}                                               <p>My headline</p>
#container {
                                               </div>
    font-size: 10px;
                                           </div>
}                      Because it comes last
Cascade Recap
Stylesheet Order       Last Rule              Inheritance

1. External            Rules that come last   Specificity
2. Embedded (<head>)

3. Inline
Properties
Text Color
                color:	
  #ee3e80;

COLOR NAMES      RGB VALUES          Hexadecimal

147 predefined    Values for red,     Six or three digit
names            green and blue      alpha-numeral.

DarkCyan         rgb(100,100,90);    #FFFFFF;
Purple           rgb(255,255,255);   #000000;
Black            rgb(0,0,0);         #000;
Red              rgb(30,44,200);     #AF0;
Backgrounds
background-­‐color:	
  #ee3e80;

 background-­‐image:url(‘image.jpg’);
 background-­‐position:0px	
  50%;
 background-­‐repeat:repeat;

Short code
background:	
  url(‘path_to_image.jpg’)	
  no-­‐repeat	
  0px	
  0px;
Font Family
 font-­‐family:	
  Helvetica,	
  Arial,	
  san-­‐serif;

FALL BACK             QUOTES               END WITH
                                           GENERIC
A comma               Use quotes when
separated list of     a font is multiple   End with a
fonts to use if the   words, like          generic font, like
system doesnʼt        “Times New           serif or san-serif.
have the font         Roman.”              This way the
installed.                                 browser will pick
                                           for you.
Font Size
                    font-­‐size:	
  12px;

PIXELS                PERCENTAGES           EM

Pixels are            Percentages are       EM is another
considered a          relative from the     way of doing
fixed font size.       default size of the   relative
Fonts will appear     text. 100%            measurement.
at this size          means the default     Varies only
relative to the       size.                 slightly from %.
screen size.
Others
font-­‐weight:	
  normal;   line-­‐height:	
  1em;
font-­‐weight:	
  bold;     line-­‐height:	
  1.4em;
font-­‐style:	
  normal;    letter-­‐spacing:	
  1em;
font-­‐style:	
  italic;    word-­‐spacing:	
  1em;
font-­‐style:	
  oblique;   text-­‐decoration:none;

text-­‐transform:	
  uppercase;  text-­‐align:	
  left;
text-­‐transform:	
  lowercase;  text-­‐align:	
  right;
text-­‐transform:	
  capitalize; text-­‐aling:	
  center
Links
a:link      a:link              a:visited
a:visited
            Before a user       After a user clicks
a:hover     clicks on a link.   on a link.
a:active

            a:hover             a:active

            When a user         When the user
            hovers over a       clicks down on a
            link.               link.
Border, Margin and Padding
margin-­‐top:10px;
margin-­‐right:10px;
margin-­‐bottom:10px;
margin-­‐left:10px;
                                       hello
                              Margin    Border   Padding


margin:5px	
  10px	
  6px	
  5px;       Width
borders
border-­‐color
border-­‐width             Single sides

                 border-­‐top-­‐color:#ffffff;
border-­‐style   border-­‐left-­‐width:	
  20px;

solid
dotted                      Combined
dashed           border:1px	
  solid	
  #000000;
groove
...
Inline vs Block
                               Inline                                                                 block

                                                                     Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                                                                     sed do eiusmod tempor incididunt ut labore et dolore
                                                                     magna aliqua.

                           Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad
                                                          <img>      List of the best pies                                       <p>
minim veniam, quis nostrud exercitation ullamco laboris   <span>      • Apple                                                    <div>
nisi ut aliquip ex ea commodo consequat. Duis aute                    • Cherry
irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur
                                                          <strong>    • Pumpkin                                                  <li>
sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
                                                          <em>                                                                   <h1>
Inline vs Block
display:inline;
display:block;
display:none;

display:block;        display:inline;

• Apple
• Cherry             • Apple • Cherry • Pumpkin
• Pumpkin
Visibility
visibility:visible;    visibility:hidden;



     Hi Mom!
CSS Reset
CSS Reset
html,	
  body,	
  div,	
  span,	
  applet,	
  object,	
  iframe,	
  h1,	
  h2,	
  h3,	
  h4,	
  h5,	
  h6,	
  
p,	
  blockquote,	
  pre,	
  a,	
  abbr,	
  acronym,	
  address,	
  big,	
  cite,	
  code,	
  del,	
  
dfn,	
  em,	
  img,	
  ins,	
  kbd,	
  q,	
  s,	
  samp,	
  small,	
  strike,	
  strong,	
  sub,	
  sup,	
  
tt,	
  var,	
  b,	
  u,	
  i,	
  center,	
  dl,	
  dt,	
  dd,	
  ol,	
  ul,	
  li,	
  fieldset,	
  form,	
  
label,	
  legend,	
  table,	
  caption,	
  tbody,	
  tfoot,	
  thead,	
  tr,	
  th,	
  td,	
  
article,	
  aside,	
  canvas,	
  details,	
  embed,	
  figure,	
  figcaption,	
  footer,	
  
header,	
  hgroup,	
  menu,	
  nav,	
  output,	
  ruby,	
  section,	
  summary,	
  time,	
  mark,	
  
audio,	
  video	
  {
	
   margin:	
  0;
	
   padding:	
  0;
	
   border:	
  0;
	
   font-­‐size:	
  100%;
	
   font:	
  inherit;
	
   vertical-­‐align:	
  baseline;
}

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (20)

CSS - chained classes
CSS - chained classesCSS - chained classes
CSS - chained classes
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
Understanding DIVs
Understanding DIVsUnderstanding DIVs
Understanding DIVs
 
Inline, Block and Positioning in CSS
Inline, Block and Positioning in CSSInline, Block and Positioning in CSS
Inline, Block and Positioning in CSS
 
Jquery plugins
Jquery pluginsJquery plugins
Jquery plugins
 
Event handling63
Event handling63Event handling63
Event handling63
 
13. session 13 introduction to dhtml
13. session 13   introduction to dhtml13. session 13   introduction to dhtml
13. session 13 introduction to dhtml
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event Model
 
Dhtml
DhtmlDhtml
Dhtml
 
Open Source and Open Data in the Age of the Cloud
Open Source and Open Data in the Age of the CloudOpen Source and Open Data in the Age of the Cloud
Open Source and Open Data in the Age of the Cloud
 
Css Positioning Elements
Css Positioning ElementsCss Positioning Elements
Css Positioning Elements
 
CSS tutorial
CSS tutorialCSS tutorial
CSS tutorial
 
Css advance
Css   advanceCss   advance
Css advance
 
Estandares y UTF-8 Matrimonio perfecto para aplicaciones multilingues
Estandares y UTF-8 Matrimonio perfecto para aplicaciones multilinguesEstandares y UTF-8 Matrimonio perfecto para aplicaciones multilingues
Estandares y UTF-8 Matrimonio perfecto para aplicaciones multilingues
 
Estilos cascadas
Estilos cascadasEstilos cascadas
Estilos cascadas
 
Tutorial css
Tutorial cssTutorial css
Tutorial css
 
Groopify para groopies
Groopify para groopiesGroopify para groopies
Groopify para groopies
 
Clase 07 04 08
Clase 07 04 08Clase 07 04 08
Clase 07 04 08
 
"Primeros pasos en una start up" por @yusefmartins
"Primeros pasos en una start up" por @yusefmartins"Primeros pasos en una start up" por @yusefmartins
"Primeros pasos en una start up" por @yusefmartins
 

Ähnlich wie CSS Tutorial

Div Tag Tutorial
Div Tag TutorialDiv Tag Tutorial
Div Tag Tutorialbav123
 
Css for Development
Css for DevelopmentCss for Development
Css for Developmenttsengsite
 
ACSS: Rethinking CSS Best Practices
ACSS: Rethinking CSS Best PracticesACSS: Rethinking CSS Best Practices
ACSS: Rethinking CSS Best PracticesRenato Iwashima
 
モダンなCSS設計パターンを考える
モダンなCSS設計パターンを考えるモダンなCSS設計パターンを考える
モダンなCSS設計パターンを考える拓樹 谷
 
RSS: the duct tape of web2.0
RSS: the duct tape of web2.0RSS: the duct tape of web2.0
RSS: the duct tape of web2.0Rob Clark
 

Ähnlich wie CSS Tutorial (6)

Div Tag Tutorial
Div Tag TutorialDiv Tag Tutorial
Div Tag Tutorial
 
Css for Development
Css for DevelopmentCss for Development
Css for Development
 
ACSS: Rethinking CSS Best Practices
ACSS: Rethinking CSS Best PracticesACSS: Rethinking CSS Best Practices
ACSS: Rethinking CSS Best Practices
 
モダンなCSS設計パターンを考える
モダンなCSS設計パターンを考えるモダンなCSS設計パターンを考える
モダンなCSS設計パターンを考える
 
What is HTML5?
What is HTML5?What is HTML5?
What is HTML5?
 
RSS: the duct tape of web2.0
RSS: the duct tape of web2.0RSS: the duct tape of web2.0
RSS: the duct tape of web2.0
 

Mehr von UC Berkeley Graduate School of Journalism (6)

Jquery News Packages
Jquery News PackagesJquery News Packages
Jquery News Packages
 
HTML News Packages Lesson
HTML News Packages LessonHTML News Packages Lesson
HTML News Packages Lesson
 
Quiz
QuizQuiz
Quiz
 
The 960 Grid System
The 960 Grid SystemThe 960 Grid System
The 960 Grid System
 
Intro to CSS
Intro to CSSIntro to CSS
Intro to CSS
 
Intro to HTML
Intro to HTMLIntro to HTML
Intro to HTML
 

Kürzlich hochgeladen

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 

Kürzlich hochgeladen (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

CSS Tutorial

  • 2. Parts of a CSS rule h2 { color: #000000; }
  • 3. Parts of a CSS rule h2 { color: #000000; } SELECTOR
  • 4. Parts of a CSS rule h2 { color: #000000; } CURLY BRACKETS
  • 5. Parts of a CSS rule h2 { color: #000000; } PROPERTY
  • 6. Parts of a CSS rule h2 { color: #000000; } VALUE
  • 7. Parts of a CSS rule h2 { color: #000000; } START WITH SELECTOR
  • 8. Three Kinds of Selectors TYPE SELECTORS CLASS SELECTORS ID SELECTORS div .headlines #container p .paragraphs #first-­‐article h2 .bylines #footer strong .summary #sidebar
  • 9. Type Selectors <body> h2 { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-style: bold; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> p{ <div id=“sidebar”> <h2>Side Bar Story</h2> <p class=“byline”>By John Doe.</p> font-family: Helvetica; <p>This is a related story.</p> </div> } </div> </body>
  • 10. Type Selectors <body> h2 { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-style: bold; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> p{ <div id=“sidebar”> <h2>Side Bar Story</h2> <p class=“byline”>By John Doe.</p> font-family: Helvetica; <p>This is a related story.</p> </div> } </div> </body>
  • 11. Class Selectors <body> .headline { <div id=“container”> <h2 class=“headline”>Hello World</h2> text-decoration: underline; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> .byline { <div id=“sidebar”> <h2>Side Bar Story</h2> <p class=“byline”>By John Doe.</p> font-size: 8px; <p>This is a related story.</p> </div> } </div> </body>
  • 12. Class Selectors <body> .headline { <div id=“container”> <h2 class=“headline”>Hello World</h2> text-decoration: underline; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> .byline { <div id=“sidebar”> <h2>Side Bar Story</h2> <p class=“byline”>By John Doe.</p> font-size: 8px; <p>This is a related story.</p> </div> } </div> </body>
  • 13. ID Selectors <body> #container { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> #sidebar { <div id=“sidebar”> <h2>Side Bar Story</h2> <p class=“byline”>By John Doe.</p> font-size: 8px; <p>This is a related story.</p> </div> } </div> </body>
  • 14. ID Selectors <body> #container { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> #sidebar { <div id=“sidebar”> <h2>Side Bar Story</h2> <p class=“byline”>By John Doe.</p> font-size: 8px; <p>This is a related story.</p> </div> } </div> </body>
  • 15. More ways to use selectors
  • 16. More Selector Options <body> .headline{ <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> <div id=“sidebar”> <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 17. More Selector Options <body> h2.headline { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> <div id=“sidebar”> <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 18. More Selector Options <body> #sidebar p { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> A space means <div id=“sidebar”> descendant. <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 19. More Selector Options <body> #container #sidebar h3 { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> <div id=“sidebar”> <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 20. More Selector Options <body> #container #sidebar h3 { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> <div id=“sidebar”> <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 21. More Selector Options <body> #container #sidebar h3 { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> <div id=“sidebar”> <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 22. More Selector Options <body> #container #sidebar h3 { <div id=“container”> <h2 class=“headline”>Hello World</h2> font-size: 30px; <p class=“byline”>By Jeremy Rue.</p> } <p>In todayʼs news, a class at UC Berkeley learned the importance of CSS in designing and building webpages.</p> <div id=“sidebar”> <h3 class=“headline”>Side Bar Story</h3> <p class=“byline”>By John Doe.</p> <p>This is a related story.</p> </div> </div> </body>
  • 23. NOT to be confused with...
  • 24. HTML vs CSS HTML CSS <div class=“headline lead-story article”> .headline p { } These spaces give multiple classes This space means a <p> tag inside another tag with class .headline
  • 25. Example from Richmond Site <div id="post-38661" class="hentry p1 post publish author-lexi- pandell category-education category-featured category-front tag-big-brother-big-sister tag-mentoring tag-nonprofit tag- youth y2012 m02 d07 h13">
  • 26. A few others <div id=“container”> h3, p { color:orange; } <h3>Here is one headline</h3> <div> <h3>Another</h3> <p>Some text here</p> </div> <p>Another paragraph.</p> <h3>Last graph.</h3> </div>
  • 27. A few others <div id=“container”> #container > h3 { color:orange; } <h3>Here is one headline</h3> <div> <h3>Another</h3> <p>Some text here</p> </div> <p>Another paragraph.</p> <h3>Last graph.</h3> </div>
  • 28. A few others <div id=“container”> h3 + p { color:orange; } <h3>Here is one headline</h3> <div> <h3>Another</h3> <p>Some text here</p> </div> <p>Another paragraph.</p> <h3>Last graph.</h3> </div>
  • 29. A few others <div id=“container”> h3:first-child { color:orange; } <h3>Here is one headline</h3> <div> <h3>Another</h3> <p>Some text here</p> </div> <p>Another paragraph.</p> <h3>Last graph.</h3> </div>
  • 31. What happens if there is a conflict? External Style Sheet Embedded Style Sheet Inline Styles <head> <style> .headlines { <div style= “color:black;”> color:black; } </style> </head> The more specific rules take precedence.
  • 32. Which rule wins out? #container { <div id="container"> font-size: 30px; <div id="headline"> } <p>My headline</p> #headline { </div> font-size: 10px; </div> }
  • 33. Which rule wins out? #container { <div id="container"> font-size: 30px; <div id="headline"> } <p>My headline</p> #container { </div> font-size: 10px; </div> } Because it comes last
  • 34. Cascade Recap Stylesheet Order Last Rule Inheritance 1. External Rules that come last Specificity 2. Embedded (<head>) 3. Inline
  • 36. Text Color color:  #ee3e80; COLOR NAMES RGB VALUES Hexadecimal 147 predefined Values for red, Six or three digit names green and blue alpha-numeral. DarkCyan rgb(100,100,90); #FFFFFF; Purple rgb(255,255,255); #000000; Black rgb(0,0,0); #000; Red rgb(30,44,200); #AF0;
  • 37. Backgrounds background-­‐color:  #ee3e80; background-­‐image:url(‘image.jpg’); background-­‐position:0px  50%; background-­‐repeat:repeat; Short code background:  url(‘path_to_image.jpg’)  no-­‐repeat  0px  0px;
  • 38. Font Family font-­‐family:  Helvetica,  Arial,  san-­‐serif; FALL BACK QUOTES END WITH GENERIC A comma Use quotes when separated list of a font is multiple End with a fonts to use if the words, like generic font, like system doesnʼt “Times New serif or san-serif. have the font Roman.” This way the installed. browser will pick for you.
  • 39. Font Size font-­‐size:  12px; PIXELS PERCENTAGES EM Pixels are Percentages are EM is another considered a relative from the way of doing fixed font size. default size of the relative Fonts will appear text. 100% measurement. at this size means the default Varies only relative to the size. slightly from %. screen size.
  • 40. Others font-­‐weight:  normal; line-­‐height:  1em; font-­‐weight:  bold; line-­‐height:  1.4em; font-­‐style:  normal; letter-­‐spacing:  1em; font-­‐style:  italic; word-­‐spacing:  1em; font-­‐style:  oblique; text-­‐decoration:none; text-­‐transform:  uppercase; text-­‐align:  left; text-­‐transform:  lowercase; text-­‐align:  right; text-­‐transform:  capitalize; text-­‐aling:  center
  • 41. Links a:link a:link a:visited a:visited Before a user After a user clicks a:hover clicks on a link. on a link. a:active a:hover a:active When a user When the user hovers over a clicks down on a link. link.
  • 42. Border, Margin and Padding margin-­‐top:10px; margin-­‐right:10px; margin-­‐bottom:10px; margin-­‐left:10px; hello Margin Border Padding margin:5px  10px  6px  5px; Width
  • 43. borders border-­‐color border-­‐width Single sides border-­‐top-­‐color:#ffffff; border-­‐style border-­‐left-­‐width:  20px; solid dotted Combined dashed border:1px  solid  #000000; groove ...
  • 44. Inline vs Block Inline block Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad <img> List of the best pies <p> minim veniam, quis nostrud exercitation ullamco laboris <span> • Apple <div> nisi ut aliquip ex ea commodo consequat. Duis aute • Cherry irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur <strong> • Pumpkin <li> sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <em> <h1>
  • 45. Inline vs Block display:inline; display:block; display:none; display:block; display:inline; • Apple • Cherry • Apple • Cherry • Pumpkin • Pumpkin
  • 46. Visibility visibility:visible; visibility:hidden; Hi Mom!
  • 48. CSS Reset html,  body,  div,  span,  applet,  object,  iframe,  h1,  h2,  h3,  h4,  h5,  h6,   p,  blockquote,  pre,  a,  abbr,  acronym,  address,  big,  cite,  code,  del,   dfn,  em,  img,  ins,  kbd,  q,  s,  samp,  small,  strike,  strong,  sub,  sup,   tt,  var,  b,  u,  i,  center,  dl,  dt,  dd,  ol,  ul,  li,  fieldset,  form,   label,  legend,  table,  caption,  tbody,  tfoot,  thead,  tr,  th,  td,   article,  aside,  canvas,  details,  embed,  figure,  figcaption,  footer,   header,  hgroup,  menu,  nav,  output,  ruby,  section,  summary,  time,  mark,   audio,  video  {   margin:  0;   padding:  0;   border:  0;   font-­‐size:  100%;   font:  inherit;   vertical-­‐align:  baseline; }