SlideShare una empresa de Scribd logo
1 de 40
CSS
CASCADING STYLE SHEETS




        Mukesh N. Tekwani
        Computer Science & Physics
        mukeshtekwani@hotmail.com
        I. Y. College, Mumbai, India
WHAT IS CSS?




                                                           January 2012
 CSS stands for Cascading Style Sheets
 CSS defines HOW to display HTML elements




                                                           Prof. Mukesh N. Tekwani
 Styles are normally stored in Style Sheets

 External Style Sheets can save you a lot of work

 External Style Sheets are stored in CSS files

 Multiple style definitions will cascade into one

 CSS selects an element and sets the rules for that
  element. These set of rules are known as style
  sheets and can be in the HEAD section of an HTML
  document or in an external style sheet.
                                                       2
CSS RULES




                                                                    January 2012
   A CSS rule has 2 parts: a selector, and one or more
    declarations:




                                                                    Prof. Mukesh N. Tekwani
    Selector            Declaration
    H1                  {color:blue; font-size:12px;)
    Here, color is the property and blue is the value of that
    property.

    The selector is the HTML element that we want to style.
    The property is the attribute we want to change. Each
    attribute has a value.

    CSS property names are separated by dashes when
    they are multiple words—for example, font-face, font-       3
    size, line-height, and so on.
WHAT IS THE NEED FOR CSS?
(OR WHAT ARE THE ADVANTAGES OF CSS?)




                                                             January 2012
   HTML pages use a lot of markup to style the pages.




                                                             Prof. Mukesh N. Tekwani
   There can be very complex structures of
    tables, nested frames, invisible pixel images for
    layout, etc.

   This makes HTML page difficult to render for the
    browser.



                                                         4
WHAT IS THE NEED FOR CSS?
(OR WHAT ARE THE ADVANTAGES OF CSS?)




                                                                          January 2012
   Code: CSS is the standard for coding in HTML. CSS is
    compatible with most browsers. CSS reduces the length of the
    codes of web page, which decreases the page size, making it
    easy and fast to load in browsers




                                                                          Prof. Mukesh N. Tekwani
   Design: Use of CSS makes the design simple. CSS makes the
    management of the entire website easy to maintain by just
    changing the CSS file which contains the style details.

   Bandwidth: CSS reduces the HTML coding and page size. This
    reduces the bandwidth usage.

   Consistency: It is easy to maintain, handle and control the
    whole website made on CSS based HTML. Ex: Suppose we want
    to change the background of the entire website, we just need to
    change the background of the single page in the style sheet and
    the background of the whole website will change.                  5
WHAT IS MEANT BY STYLE RULES?




                                                               January 2012
   A style rule is used to change the default behavior
    of an HTML element. All style rules are contained in




                                                               Prof. Mukesh N. Tekwani
    the <STYLE> element and this is put in the HEAD
    section of an HTML document.

   A style rule is made up of 2 parts: a selector and a
    declaration. The selector determines the element
    to which the style is to be applied. The declaration
    gives the exact property values.


                                                           6
WHAT IS MEANT BY STYLE RULES?




                                                                        January 2012
   Consider the <P> element. We can create a style rule for this
    <P> element so that all paragraphs are in blue color and have
    a font size of 24px. The style rule is as follows:




                                                                        Prof. Mukesh N. Tekwani
<STYLE>
  P {COLOR:BLUE; FONT-SIZE:24px}
</STYLE>

   Consider the <H1> element. We can create a style for this
    element so that all H1 headings are in red color.

<STYLE TYPE = “TEXT/CSS”>
  H1 {COLOR:RED}
                                                                    7
</STYLE>
DEFINING THE STYLE FOR A SINGLE ELEMENT:




                                                               January 2012
   We can define the style for a single element as
    follows:




                                                               Prof. Mukesh N. Tekwani
    <H1 STYLE =”COLOR:BLUE”>This is a
    heading</H1>

   This direct use of CSS is called inline style and is
    not recommended due to the tight coupling
    between the HTML document and the style.

                                                           8
TRY…




                                                           January 2012
   Write a style rule so that every <H1> element on
    your web site is in green color and centered.




                                                           Prof. Mukesh N. Tekwani
H1     {COLOR:GREEN; TEXT-ALIGN:CENTER}




                                                       9
EXTERNAL STYLE SHEET:




                                                             January 2012
   Placing style sheets in an external document lets
    you specify rules for different HTML documents. An




                                                             Prof. Mukesh N. Tekwani
    external style sheet is a text document with the file
    name extension of .CSS. This external style sheet
    contains the style rules for various elements.




                                                            10
EXTERNAL STYLE SHEET:




                                                                   January 2012
  /* stylesheet 1 */
  H1 {COLOR:GREEN}
  H2 {COLOR:GREEN; BORDER:SOLID BLUE}




                                                                   Prof. Mukesh N. Tekwani
  (Other option for SOLID is DOTTED)
  The CSS line begins with a comment. The CSS style sheet
  does not contain any HTML code.

  To link this external style sheet to an HTML document, we add
  the <LINK> element in the HEAD section of an HTML
  document:

<HEAD>
<TITLE>Sample document</TITLE>
<LINK HREF = “style1.css” REL = “stylesheet”>
</HEAD>                                                           11
EXTERNAL STYLE SHEET:




                                                            January 2012
   The HTML file containing this code displays with the
    characteristics given in the style sheet.




                                                            Prof. Mukesh N. Tekwani
   The HREF attribute gives the URL of the stylesheet.
    The REL attribute specifies the relationship
    between the linked and the current document.

   The major advantage of external style sheets is
    that the styles can apply to all the web pages on a
    site. In order to make global changes, we just have
    to modify the external style sheet.
                                                           12
DIFFERENT         CSS SELECTION TECHNIQUES




                                                                           January 2012
Selecting Multiple Elements:
  By using multiple selectors, we can use less code. E.g., to make both
  <H1> and <H2> headings green, we can use the following rules:




                                                                           Prof. Mukesh N. Tekwani
  <STYLE TYPE = “TEXT/CSS”>
       <H1> {COLOR:GREEN}
       <H2> {COLOR:GREEN}
  </STYLE>


  These two rules can be expressed in a single rule statement using
  multiple selectors for the same property as follows:

  <STYLE TYPE = “TEXT/CSS”>
       H1, H2 {COLOR:GREEN}
  </STYLE>
                                                                          13
DIFFERENT        CSS SELECTION TECHNIQUES




                                                                          January 2012
Selecting by Context:
  A context-based selector lets you specify the exact context in
  which a style is applied.




                                                                          Prof. Mukesh N. Tekwani
  For example, to specify that the <I> elements appear in blue
  color only within the <H1> elements, we create the style rule as
  follows:
  <STYLE TYPE = “TEXT/CSS”>
        H1 I {COLOR:BLUE}
  </STYLE>

  Note: We should not place a comma between the element H1
  and I in the above example. Otherwise it will turn a contextual
  selection into a multiple element selection and blue color text will
  apply to both H1 headings and Italic text.
                                                                         14
  So don’t write this: H1 , I {COLOR:BLUE}
DIFFERENT        CSS SELECTION TECHNIQUES




                                                                          January 2012
Selecting with the CLASS attribute:
  The CLASS attribute lets you write rules and then apply them to
  groups of elements. Basically the CLASS attribute lets you define




                                                                          Prof. Mukesh N. Tekwani
  your own tags and apply them wherever you want.

  To create a class, we first declare it within the <STYLE> element.
  The period (.) flag character indicates that the selector is a class
  selector.

  <STYLE TYPE = “TEXT/CSS”>
        .QUOTE {COLOR:RED}
  </STYLE>

  Applying this style to a paragraph:
  <P CLASS=”QUOTE”> This is a paragraph </P>                             15
WHAT ARE THE CSS FONT PROPERTIES?




                                                         January 2012
 The following font properties can be controlled with
 CSS:




                                                         Prof. Mukesh N. Tekwani
    Font families and alternates
    Font size
    Font weight
    Line height
    Letter spacing
    Text indent
                                                        16
    Color
WHAT ARE THE CSS FONT PROPERTIES?




                                            January 2012
 Example 1: Create a style rule that
 specifies Arial as the font for the <P>




                                            Prof. Mukesh N. Tekwani
 element.

 <STYLE TYPE=”TEXT/CSS”>
    P {FONT-FAMILY:ARIAL}
 </STYLE>


                                           17
WHAT ARE THE CSS FONT PROPERTIES?




                                            January 2012
 Example 2: Create a style rule that
 specifies Arial as the font for the <P>




                                            Prof. Mukesh N. Tekwani
 element. In case Arial font is not
 available, use the Helvetica font.

 <STYLE TYPE=”TEXT/CSS”>
 P {FONT-FAMILY:ARIAL, HELVETICA}
 </STYLE>

                                           18
WHAT ARE THE CSS FONT PROPERTIES?




                                                   January 2012
 Example 3: Create a style rule that specifies
 Arial as the font for the <P> element. In case
 Arial font is not available, use the Helvetica




                                                   Prof. Mukesh N. Tekwani
 font. In case this too is not available, use a
 generic font like sans-serif.

 <STYLE TYPE=”TEXT/CSS”>
     P {FONT-FAMILY:ARIAL, HELVETICA,
     SANS-SERIF}
 </STYLE>

 The generic names we can use are:
 Monospace, Serif and Sans-serif.                 19
WHAT ARE THE CSS FONT PROPERTIES?




                                                    January 2012
Specifying Text Background Color:
 Example 4: We can set the text background




                                                    Prof. Mukesh N. Tekwani
 color (i.e., the color behind the text) for any
 element, by using the BACKGROUND-
 COLOR property, as follows:

 <STYLE TYPE=”TEXT/CSS”>
    H2 {COLOR:WHITE; BACKGROUND-
 COLOR:BLUE}
 </STYLE>
                                                   20
WHAT IS THE CLASS SELECTOR IN CSS?




                                                                            January 2012
   The CLASS attribute lets you write rules and then apply them to
    groups of elements.
   The CLASS attribute lets you define your own tags and apply




                                                                            Prof. Mukesh N. Tekwani
    them wherever you want.

    To create a class, we first declare it within the <STYLE> element.
    The period (.) flag character indicates that the selector is a class
    selector.

    <STYLE TYPE = “TEXT/CSS”>
          .QUOTE {COLOR:RED}
    </STYLE>

    Applying this style to a paragraph:
    <P CLASS=”QUOTE”> This is a paragraph </P>                             21
WHAT IS THE CLASS SELECTOR IN CSS?




                                                                                  January 2012
 Example 2: Create a class rule called “veryimportant” that sets the background
 color to yellow. Apply this to a H1 heading and two paragraphs. Also show how
 a para is rendered if the class is not applied to it.




                                                                                  Prof. Mukesh N. Tekwani
 <HTML>
 <HEAD>
 <STYLE TYPE="TEXT/CSS">
       .veryimportant {background-color: yellow;}
 </STYLE>
 </HEAD>
 <BODY>
      <H1 CLASS="veryimportant">Example</h1>
      <P CLASS="veryimportant">This is the first paragraph.</P>
      <P>This is the second paragraph.</P>
      <P Class="veryimportant">This is the third paragraph.</P>
 </BODY>
                                                                              22
 </HTML>
HOW TO SPECIFY TEXT MARGINS N CSS?




                                                              January 2012
 The MARGIN attribute is used to set the text margin on
 all four sides. We can also set the margins on individual
 sides with following settings:




                                                              Prof. Mukesh N. Tekwani
 MARGIN-TOP
 MARGIN-BOTTOM
 MARGIN-LEFT
 MARGIN-RIGHT

 Example: Set the margin on all sides to 30 px
 <STYLE TYPE = “TEXT/CSS”>
     P {margin:30px}
                                                             23
 </STYLE>
HOW TO SPECIFY THE TEXT BORDERS?




                                               January 2012
 The BORDER property can be used to set the
 border style, color and width.




                                               Prof. Mukesh N. Tekwani
 Syntax: {BORDER BORDER-STYLE
            BORDER-WIDTH BORDER-COLOR}

 Example
 <STYLE TYPE = “TEXT/CSS”>
     P {BORDER: SOLID 2pt BLUE}
 </STYLE>
                                              24
CHANGING BACKGROUND COLOR WITH CSS




                                      January 2012
<html>
<head>
<style type="text/css">




                                      Prof. Mukesh N. Tekwani
body
{
  background-color:#b0c45e;
}
</style>
</head>
<body>
  <h1>My CSS web page!</h1>
  <p>Hello world!</p>
</body>                              25
</html>
SET AN IMAGE AS THE BACKGROUND OF A
PAGE




                                               January 2012
<html>
<head>




                                               Prof. Mukesh N. Tekwani
<style type="text/css">
  body {background-image:url('paper.gif');}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>                                       26
EXAMPLE




                                                                  January 2012
Create a style rule as follows: To display the date in a right-
  aligned paragraph. To display the main text in a justified
  paragraph.




                                                              Prof. Mukesh N. Tekwani
<html>
<head>
<style type="text/css">
  h1 {text-align:center;}
  p.date {text-align:right;}
  p.main {text-align:justify;}
</style>
</head>                                                      27
EXAMPLE (CONTD)




                                                   January 2012
<body>
  <h1>CSS text-align Example</h1>




                                                   Prof. Mukesh N. Tekwani
  <p class="date">Nov 2010</p>
  <p class="main">This is the main paragraph in
  which text alignment is “justified”</p>
</body>
</html>




                                                  28
EXAMPLE




                                                     January 2012
Create style rules for the four states of a link.
<html>




                                                     Prof. Mukesh N. Tekwani
<head>
<style type="text/css">
  a:link {color:#FF0000;} /* unvisited link */
  a:visited {color:#00FF00;} /* visited link */
  a:hover {color:#FF00FF;} /* mouse over link */
  a:active {color:#0000FF;} /* selected link */
</style>
</head>
                                                    29
EXAMPLE (CONTD)




                                                       January 2012
<body>
  <p><b><a href="default.asp" target="_blank">




                                                       Prof. Mukesh N. Tekwani
  This is a link</a></b></p>
</body>
</html>

 Note: a:hover MUST come after a:link and a:visited
 in the CSS definition in order to be effective.
 a:active MUST come after a:hover in the CSS
 definition in order to be effective.
                                                      30
EXAMPLE




                                                         January 2012
   Create a style rule for H1 element with following
    specifications:




                                                         Prof. Mukesh N. Tekwani
      H1 tag with
      Background image: swirlbkg.jpg
      Color—green
      Letter-spacing-7pt
      Text-align- center
      Text-decoration-underline
      Text-transform--uppercase;
      Word-spacing: 2pt
                                                        31
EXAMPLE(CONTD)




                                January 2012
H1
{




                                Prof. Mukesh N. Tekwani
  color:green;
  letter-spacing:7pt;
  text-align: center;
  text-decoration:underline;
  text-transform:uppercase;
  word-spacing: 2pt
}
                               32
EXAMPLE




                                                    January 2012
   Create a style rule for P tag with following
    specifications:




                                                    Prof. Mukesh N. Tekwani
      Color – magenta
      font-family – Algerian
      font-size – medium
      font-style—italic
       font-weight—lighter




                                                   33
EXAMPLE




                             January 2012
P
{




                             Prof. Mukesh N. Tekwani
    color: magenta;
    font-family:Algerian;
    font-size: medium;
    font-style:italic;
    font-weight:-lighter;
}


                            34
EXAMPLE TO ILLUSTRATE THE VARIOUS
STYLES APPLIED TO LISTS:




                                                              January 2012
<html>
<head>




                                                              Prof. Mukesh N. Tekwani
<style type="text/css">
  ul.a {list-style-type:circle;} /* open circle */
  ul.b {list-style-type:square;} /* filled square */
  ul.e {list-style-type:disc;} /* filled circle */
  ol.c {list-style-type:upper-roman;} /* upper roman I
  */
  ol.d {list-style-type:lower-alpha;} /* lower alpha: a */
</style>
</head>
                                                             35
LISTS
<body>




                                      January 2012
<p>Example of unordered lists:</p>
  <ul class="a">




                                      Prof. Mukesh N. Tekwani
         <li>Coffee</li>
         <li>Tea</li>
         <li>Coca Cola</li>
  </ul>
  <ul class="b">
         <li>Coffee</li>
         <li>Tea</li>
         <li>Coca Cola</li>
                                     36
  </ul>
LISTS




                                      January 2012
  <ul class="e">
         <li>Coffee</li>
         <li>Tea</li>




                                      Prof. Mukesh N. Tekwani
         <li>Coca Cola</li>
  </ul>
  <p>Example of ordered lists:</p>
  <ol class="c">
         <li>Coffee</li>
         <li>Tea</li>
         <li>Coca Cola</li>
  </ol>
</body>
</html>                              37
HANGING INDENT




                                                          January 2012
Write a style rule for a <P> element with a 24 pt
hanging indent and a 30 pixel margin on left and right
sides.




                                                          Prof. Mukesh N. Tekwani
<STYLE TYPE = "TEXT/CSS">
P
{
  text-indent:-24pt;
  margin-left:30px;
  margin-right:30px
}
                                                         38
</STYLE>
ALIGNING TEXT WITH CSS
<html>




                                                                                       January 2012
<head>
<style>
h1 {text-align:center;}




                                                                                       Prof. Mukesh N. Tekwani
p.date {text-align:right;}
p.main {text-align:justify;}
</style>
</head>
<body>
<h1>CSS text-align Example</h1>
<p class="date">May, 2009</p>
<p class="main">In my younger and more vulnerable years my father gave me
   some advice that I've been turning over in my mind ever since. 'Whenever
   you feel like criticizing anyone,' he told me, just remember that all the people
   in this world haven't had the advantages that you've had.'</p>
<p><b>Note:</b> Resize the browser window to see how the value "justify"              39
  works.</p></body></html>
QUESTIONS ?




               January 2012
 Read.
 Practice.




               Prof. Mukesh N. Tekwani
 Read.

 Practice.

:

:

:




              40

Más contenido relacionado

Destacado

Cascading Style Sheets (CSS) - An introduction
Cascading Style Sheets (CSS) - An introductionCascading Style Sheets (CSS) - An introduction
Cascading Style Sheets (CSS) - An introductionrachaelboyer
 
Curso de cascading style sheets (css)
Curso de cascading style sheets (css)Curso de cascading style sheets (css)
Curso de cascading style sheets (css)Educagratis
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSSNosheen Qamar
 
Need for Web Engineering
Need for Web EngineeringNeed for Web Engineering
Need for Web EngineeringNosheen Qamar
 
HTML Link - Image - Comments
HTML  Link - Image - CommentsHTML  Link - Image - Comments
HTML Link - Image - CommentsHameda Hurmat
 
Hyperlinks in HTML
Hyperlinks in HTMLHyperlinks in HTML
Hyperlinks in HTMLAarti P
 
Cascading style sheets (css)
Cascading style sheets (css)Cascading style sheets (css)
Cascading style sheets (css)veasnarin
 
An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)Ardee Aram
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsMarc Steel
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshMukesh Kumar
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsPaul Dionysius
 
Html Css
Html CssHtml Css
Html Csspumas26
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style SheetsTushar Joshi
 
XML Schema
XML SchemaXML Schema
XML Schemayht4ever
 

Destacado (20)

Css(cascading style sheets)
Css(cascading style sheets)Css(cascading style sheets)
Css(cascading style sheets)
 
Cascading Style Sheets (CSS) - An introduction
Cascading Style Sheets (CSS) - An introductionCascading Style Sheets (CSS) - An introduction
Cascading Style Sheets (CSS) - An introduction
 
Curso de cascading style sheets (css)
Curso de cascading style sheets (css)Curso de cascading style sheets (css)
Curso de cascading style sheets (css)
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
 
Need for Web Engineering
Need for Web EngineeringNeed for Web Engineering
Need for Web Engineering
 
HTML Link - Image - Comments
HTML  Link - Image - CommentsHTML  Link - Image - Comments
HTML Link - Image - Comments
 
Hyperlinks in HTML
Hyperlinks in HTMLHyperlinks in HTML
Hyperlinks in HTML
 
Cascading style sheets (css)
Cascading style sheets (css)Cascading style sheets (css)
Cascading style sheets (css)
 
Css advanced – session 4
Css advanced – session 4Css advanced – session 4
Css advanced – session 4
 
An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)An Introduction to Cascading Style Sheets (CSS3)
An Introduction to Cascading Style Sheets (CSS3)
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Cascading Style Sheets By Mukesh
Cascading Style Sheets By MukeshCascading Style Sheets By Mukesh
Cascading Style Sheets By Mukesh
 
Cashcading stylesheets
Cashcading stylesheetsCashcading stylesheets
Cashcading stylesheets
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Css
CssCss
Css
 
Html Css
Html CssHtml Css
Html Css
 
CSS
CSSCSS
CSS
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
 
XML Schema
XML SchemaXML Schema
XML Schema
 

Similar a CSS-Cascading Style Sheets - Introduction

Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsMukesh Tekwani
 
Chapter 3 - CSS.pdf
Chapter 3 - CSS.pdfChapter 3 - CSS.pdf
Chapter 3 - CSS.pdfwubiederebe1
 
This is css which compiled by alex that is impo
This is css which compiled by alex that is impoThis is css which compiled by alex that is impo
This is css which compiled by alex that is impoAlebelAyalneh
 
CLIENT SIDE PROGRAMMING
CLIENT SIDE PROGRAMMINGCLIENT SIDE PROGRAMMING
CLIENT SIDE PROGRAMMINGProf Ansari
 
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and StyleLesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and StylePerry Mallari
 
Teaching presentation
Teaching presentationTeaching presentation
Teaching presentationjakia123
 
Unit iii css and javascript 1
Unit iii css and javascript 1Unit iii css and javascript 1
Unit iii css and javascript 1Jesus Obenita Jr.
 
Introduction of css
Introduction of cssIntroduction of css
Introduction of cssDinesh Kumar
 
lesson-1-introduction-html-and-css.pptx
lesson-1-introduction-html-and-css.pptxlesson-1-introduction-html-and-css.pptx
lesson-1-introduction-html-and-css.pptxkulmiye2
 
Shyam sunder Rajasthan Computer
Shyam sunder Rajasthan ComputerShyam sunder Rajasthan Computer
Shyam sunder Rajasthan Computershyamverma305
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationLecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationZahouAmel1
 
Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8RohanMistry15
 

Similar a CSS-Cascading Style Sheets - Introduction (20)

Css
CssCss
Css
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Chapter 3 - CSS.pdf
Chapter 3 - CSS.pdfChapter 3 - CSS.pdf
Chapter 3 - CSS.pdf
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
This is css which compiled by alex that is impo
This is css which compiled by alex that is impoThis is css which compiled by alex that is impo
This is css which compiled by alex that is impo
 
CLIENT SIDE PROGRAMMING
CLIENT SIDE PROGRAMMINGCLIENT SIDE PROGRAMMING
CLIENT SIDE PROGRAMMING
 
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and StyleLesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
 
Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
Teaching presentation
Teaching presentationTeaching presentation
Teaching presentation
 
Unit iii css and javascript 1
Unit iii css and javascript 1Unit iii css and javascript 1
Unit iii css and javascript 1
 
CSS.ppt
CSS.pptCSS.ppt
CSS.ppt
 
Introduction of css
Introduction of cssIntroduction of css
Introduction of css
 
lesson-1-introduction-html-and-css.pptx
lesson-1-introduction-html-and-css.pptxlesson-1-introduction-html-and-css.pptx
lesson-1-introduction-html-and-css.pptx
 
Shyam sunder Rajasthan Computer
Shyam sunder Rajasthan ComputerShyam sunder Rajasthan Computer
Shyam sunder Rajasthan Computer
 
Css tutorial 2012
Css tutorial 2012Css tutorial 2012
Css tutorial 2012
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType ClassificationLecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType Classification
 
Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8Advanced Web Programming Chapter 8
Advanced Web Programming Chapter 8
 
INTRODUCTIONS OF CSS
INTRODUCTIONS OF CSSINTRODUCTIONS OF CSS
INTRODUCTIONS OF CSS
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 

Más de Mukesh Tekwani

Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelComputer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelMukesh Tekwani
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfThe Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfMukesh Tekwani
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics  -  PhysicsISCE-Class 12-Question Bank - Electrostatics  -  Physics
ISCE-Class 12-Question Bank - Electrostatics - PhysicsMukesh Tekwani
 
Hexadecimal to binary conversion
Hexadecimal to binary conversion Hexadecimal to binary conversion
Hexadecimal to binary conversion Mukesh Tekwani
 
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Mukesh Tekwani
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversionMukesh Tekwani
 
Gray code to binary conversion
Gray code to binary conversion Gray code to binary conversion
Gray code to binary conversion Mukesh Tekwani
 
Decimal to Binary conversion
Decimal to Binary conversionDecimal to Binary conversion
Decimal to Binary conversionMukesh Tekwani
 
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Mukesh Tekwani
 
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prismRefraction and dispersion of light through a prism
Refraction and dispersion of light through a prismMukesh Tekwani
 
Refraction of light at a plane surface
Refraction of light at a plane surfaceRefraction of light at a plane surface
Refraction of light at a plane surfaceMukesh Tekwani
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomAtom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomMukesh Tekwani
 
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesRefraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesMukesh Tekwani
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEMukesh Tekwani
 

Más de Mukesh Tekwani (20)

Computer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube ChannelComputer Science Made Easy - Youtube Channel
Computer Science Made Easy - Youtube Channel
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdfThe Elphinstonian 1988-College Building Centenary Number (2).pdf
The Elphinstonian 1988-College Building Centenary Number (2).pdf
 
Circular motion
Circular motionCircular motion
Circular motion
 
Gravitation
GravitationGravitation
Gravitation
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
ISCE-Class 12-Question Bank - Electrostatics  -  PhysicsISCE-Class 12-Question Bank - Electrostatics  -  Physics
ISCE-Class 12-Question Bank - Electrostatics - Physics
 
Hexadecimal to binary conversion
Hexadecimal to binary conversion Hexadecimal to binary conversion
Hexadecimal to binary conversion
 
Hexadecimal to decimal conversion
Hexadecimal to decimal conversion Hexadecimal to decimal conversion
Hexadecimal to decimal conversion
 
Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversion
 
Gray code to binary conversion
Gray code to binary conversion Gray code to binary conversion
Gray code to binary conversion
 
What is Gray Code?
What is Gray Code? What is Gray Code?
What is Gray Code?
 
Decimal to Binary conversion
Decimal to Binary conversionDecimal to Binary conversion
Decimal to Binary conversion
 
Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21Video Lectures for IGCSE Physics 2020-21
Video Lectures for IGCSE Physics 2020-21
 
Refraction and dispersion of light through a prism
Refraction and dispersion of light through a prismRefraction and dispersion of light through a prism
Refraction and dispersion of light through a prism
 
Refraction of light at a plane surface
Refraction of light at a plane surfaceRefraction of light at a plane surface
Refraction of light at a plane surface
 
Spherical mirrors
Spherical mirrorsSpherical mirrors
Spherical mirrors
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atomAtom, origin of spectra Bohr's theory of hydrogen atom
Atom, origin of spectra Bohr's theory of hydrogen atom
 
Refraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lensesRefraction of light at spherical surfaces of lenses
Refraction of light at spherical surfaces of lenses
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGEISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
 
Cyber Laws
Cyber LawsCyber Laws
Cyber Laws
 
XML
XMLXML
XML
 

Último

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (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
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
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
 
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
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
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
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Último (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (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
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
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)
 
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...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
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_...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

CSS-Cascading Style Sheets - Introduction

  • 1. CSS CASCADING STYLE SHEETS Mukesh N. Tekwani Computer Science & Physics mukeshtekwani@hotmail.com I. Y. College, Mumbai, India
  • 2. WHAT IS CSS? January 2012  CSS stands for Cascading Style Sheets  CSS defines HOW to display HTML elements Prof. Mukesh N. Tekwani  Styles are normally stored in Style Sheets  External Style Sheets can save you a lot of work  External Style Sheets are stored in CSS files  Multiple style definitions will cascade into one  CSS selects an element and sets the rules for that element. These set of rules are known as style sheets and can be in the HEAD section of an HTML document or in an external style sheet. 2
  • 3. CSS RULES January 2012  A CSS rule has 2 parts: a selector, and one or more declarations: Prof. Mukesh N. Tekwani Selector Declaration H1 {color:blue; font-size:12px;) Here, color is the property and blue is the value of that property. The selector is the HTML element that we want to style. The property is the attribute we want to change. Each attribute has a value. CSS property names are separated by dashes when they are multiple words—for example, font-face, font- 3 size, line-height, and so on.
  • 4. WHAT IS THE NEED FOR CSS? (OR WHAT ARE THE ADVANTAGES OF CSS?) January 2012  HTML pages use a lot of markup to style the pages. Prof. Mukesh N. Tekwani  There can be very complex structures of tables, nested frames, invisible pixel images for layout, etc.  This makes HTML page difficult to render for the browser. 4
  • 5. WHAT IS THE NEED FOR CSS? (OR WHAT ARE THE ADVANTAGES OF CSS?) January 2012  Code: CSS is the standard for coding in HTML. CSS is compatible with most browsers. CSS reduces the length of the codes of web page, which decreases the page size, making it easy and fast to load in browsers Prof. Mukesh N. Tekwani  Design: Use of CSS makes the design simple. CSS makes the management of the entire website easy to maintain by just changing the CSS file which contains the style details.  Bandwidth: CSS reduces the HTML coding and page size. This reduces the bandwidth usage.  Consistency: It is easy to maintain, handle and control the whole website made on CSS based HTML. Ex: Suppose we want to change the background of the entire website, we just need to change the background of the single page in the style sheet and the background of the whole website will change. 5
  • 6. WHAT IS MEANT BY STYLE RULES? January 2012  A style rule is used to change the default behavior of an HTML element. All style rules are contained in Prof. Mukesh N. Tekwani the <STYLE> element and this is put in the HEAD section of an HTML document.  A style rule is made up of 2 parts: a selector and a declaration. The selector determines the element to which the style is to be applied. The declaration gives the exact property values. 6
  • 7. WHAT IS MEANT BY STYLE RULES? January 2012  Consider the <P> element. We can create a style rule for this <P> element so that all paragraphs are in blue color and have a font size of 24px. The style rule is as follows: Prof. Mukesh N. Tekwani <STYLE> P {COLOR:BLUE; FONT-SIZE:24px} </STYLE>  Consider the <H1> element. We can create a style for this element so that all H1 headings are in red color. <STYLE TYPE = “TEXT/CSS”> H1 {COLOR:RED} 7 </STYLE>
  • 8. DEFINING THE STYLE FOR A SINGLE ELEMENT: January 2012  We can define the style for a single element as follows: Prof. Mukesh N. Tekwani <H1 STYLE =”COLOR:BLUE”>This is a heading</H1>  This direct use of CSS is called inline style and is not recommended due to the tight coupling between the HTML document and the style. 8
  • 9. TRY… January 2012  Write a style rule so that every <H1> element on your web site is in green color and centered. Prof. Mukesh N. Tekwani H1 {COLOR:GREEN; TEXT-ALIGN:CENTER} 9
  • 10. EXTERNAL STYLE SHEET: January 2012  Placing style sheets in an external document lets you specify rules for different HTML documents. An Prof. Mukesh N. Tekwani external style sheet is a text document with the file name extension of .CSS. This external style sheet contains the style rules for various elements. 10
  • 11. EXTERNAL STYLE SHEET: January 2012 /* stylesheet 1 */ H1 {COLOR:GREEN} H2 {COLOR:GREEN; BORDER:SOLID BLUE} Prof. Mukesh N. Tekwani (Other option for SOLID is DOTTED) The CSS line begins with a comment. The CSS style sheet does not contain any HTML code. To link this external style sheet to an HTML document, we add the <LINK> element in the HEAD section of an HTML document: <HEAD> <TITLE>Sample document</TITLE> <LINK HREF = “style1.css” REL = “stylesheet”> </HEAD> 11
  • 12. EXTERNAL STYLE SHEET: January 2012  The HTML file containing this code displays with the characteristics given in the style sheet. Prof. Mukesh N. Tekwani  The HREF attribute gives the URL of the stylesheet. The REL attribute specifies the relationship between the linked and the current document.  The major advantage of external style sheets is that the styles can apply to all the web pages on a site. In order to make global changes, we just have to modify the external style sheet. 12
  • 13. DIFFERENT CSS SELECTION TECHNIQUES January 2012 Selecting Multiple Elements: By using multiple selectors, we can use less code. E.g., to make both <H1> and <H2> headings green, we can use the following rules: Prof. Mukesh N. Tekwani <STYLE TYPE = “TEXT/CSS”> <H1> {COLOR:GREEN} <H2> {COLOR:GREEN} </STYLE> These two rules can be expressed in a single rule statement using multiple selectors for the same property as follows: <STYLE TYPE = “TEXT/CSS”> H1, H2 {COLOR:GREEN} </STYLE> 13
  • 14. DIFFERENT CSS SELECTION TECHNIQUES January 2012 Selecting by Context: A context-based selector lets you specify the exact context in which a style is applied. Prof. Mukesh N. Tekwani For example, to specify that the <I> elements appear in blue color only within the <H1> elements, we create the style rule as follows: <STYLE TYPE = “TEXT/CSS”> H1 I {COLOR:BLUE} </STYLE> Note: We should not place a comma between the element H1 and I in the above example. Otherwise it will turn a contextual selection into a multiple element selection and blue color text will apply to both H1 headings and Italic text. 14 So don’t write this: H1 , I {COLOR:BLUE}
  • 15. DIFFERENT CSS SELECTION TECHNIQUES January 2012 Selecting with the CLASS attribute: The CLASS attribute lets you write rules and then apply them to groups of elements. Basically the CLASS attribute lets you define Prof. Mukesh N. Tekwani your own tags and apply them wherever you want. To create a class, we first declare it within the <STYLE> element. The period (.) flag character indicates that the selector is a class selector. <STYLE TYPE = “TEXT/CSS”> .QUOTE {COLOR:RED} </STYLE> Applying this style to a paragraph: <P CLASS=”QUOTE”> This is a paragraph </P> 15
  • 16. WHAT ARE THE CSS FONT PROPERTIES? January 2012 The following font properties can be controlled with CSS: Prof. Mukesh N. Tekwani  Font families and alternates  Font size  Font weight  Line height  Letter spacing  Text indent 16  Color
  • 17. WHAT ARE THE CSS FONT PROPERTIES? January 2012 Example 1: Create a style rule that specifies Arial as the font for the <P> Prof. Mukesh N. Tekwani element. <STYLE TYPE=”TEXT/CSS”> P {FONT-FAMILY:ARIAL} </STYLE> 17
  • 18. WHAT ARE THE CSS FONT PROPERTIES? January 2012 Example 2: Create a style rule that specifies Arial as the font for the <P> Prof. Mukesh N. Tekwani element. In case Arial font is not available, use the Helvetica font. <STYLE TYPE=”TEXT/CSS”> P {FONT-FAMILY:ARIAL, HELVETICA} </STYLE> 18
  • 19. WHAT ARE THE CSS FONT PROPERTIES? January 2012 Example 3: Create a style rule that specifies Arial as the font for the <P> element. In case Arial font is not available, use the Helvetica Prof. Mukesh N. Tekwani font. In case this too is not available, use a generic font like sans-serif. <STYLE TYPE=”TEXT/CSS”> P {FONT-FAMILY:ARIAL, HELVETICA, SANS-SERIF} </STYLE> The generic names we can use are: Monospace, Serif and Sans-serif. 19
  • 20. WHAT ARE THE CSS FONT PROPERTIES? January 2012 Specifying Text Background Color: Example 4: We can set the text background Prof. Mukesh N. Tekwani color (i.e., the color behind the text) for any element, by using the BACKGROUND- COLOR property, as follows: <STYLE TYPE=”TEXT/CSS”> H2 {COLOR:WHITE; BACKGROUND- COLOR:BLUE} </STYLE> 20
  • 21. WHAT IS THE CLASS SELECTOR IN CSS? January 2012  The CLASS attribute lets you write rules and then apply them to groups of elements.  The CLASS attribute lets you define your own tags and apply Prof. Mukesh N. Tekwani them wherever you want. To create a class, we first declare it within the <STYLE> element. The period (.) flag character indicates that the selector is a class selector. <STYLE TYPE = “TEXT/CSS”> .QUOTE {COLOR:RED} </STYLE> Applying this style to a paragraph: <P CLASS=”QUOTE”> This is a paragraph </P> 21
  • 22. WHAT IS THE CLASS SELECTOR IN CSS? January 2012 Example 2: Create a class rule called “veryimportant” that sets the background color to yellow. Apply this to a H1 heading and two paragraphs. Also show how a para is rendered if the class is not applied to it. Prof. Mukesh N. Tekwani <HTML> <HEAD> <STYLE TYPE="TEXT/CSS"> .veryimportant {background-color: yellow;} </STYLE> </HEAD> <BODY> <H1 CLASS="veryimportant">Example</h1> <P CLASS="veryimportant">This is the first paragraph.</P> <P>This is the second paragraph.</P> <P Class="veryimportant">This is the third paragraph.</P> </BODY> 22 </HTML>
  • 23. HOW TO SPECIFY TEXT MARGINS N CSS? January 2012 The MARGIN attribute is used to set the text margin on all four sides. We can also set the margins on individual sides with following settings: Prof. Mukesh N. Tekwani MARGIN-TOP MARGIN-BOTTOM MARGIN-LEFT MARGIN-RIGHT Example: Set the margin on all sides to 30 px <STYLE TYPE = “TEXT/CSS”> P {margin:30px} 23 </STYLE>
  • 24. HOW TO SPECIFY THE TEXT BORDERS? January 2012 The BORDER property can be used to set the border style, color and width. Prof. Mukesh N. Tekwani Syntax: {BORDER BORDER-STYLE BORDER-WIDTH BORDER-COLOR} Example <STYLE TYPE = “TEXT/CSS”> P {BORDER: SOLID 2pt BLUE} </STYLE> 24
  • 25. CHANGING BACKGROUND COLOR WITH CSS January 2012 <html> <head> <style type="text/css"> Prof. Mukesh N. Tekwani body { background-color:#b0c45e; } </style> </head> <body> <h1>My CSS web page!</h1> <p>Hello world!</p> </body> 25 </html>
  • 26. SET AN IMAGE AS THE BACKGROUND OF A PAGE January 2012 <html> <head> Prof. Mukesh N. Tekwani <style type="text/css"> body {background-image:url('paper.gif');} </style> </head> <body> <h1>Hello World!</h1> </body> </html> 26
  • 27. EXAMPLE January 2012 Create a style rule as follows: To display the date in a right- aligned paragraph. To display the main text in a justified paragraph. Prof. Mukesh N. Tekwani <html> <head> <style type="text/css"> h1 {text-align:center;} p.date {text-align:right;} p.main {text-align:justify;} </style> </head> 27
  • 28. EXAMPLE (CONTD) January 2012 <body> <h1>CSS text-align Example</h1> Prof. Mukesh N. Tekwani <p class="date">Nov 2010</p> <p class="main">This is the main paragraph in which text alignment is “justified”</p> </body> </html> 28
  • 29. EXAMPLE January 2012 Create style rules for the four states of a link. <html> Prof. Mukesh N. Tekwani <head> <style type="text/css"> a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */ </style> </head> 29
  • 30. EXAMPLE (CONTD) January 2012 <body> <p><b><a href="default.asp" target="_blank"> Prof. Mukesh N. Tekwani This is a link</a></b></p> </body> </html> Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective. a:active MUST come after a:hover in the CSS definition in order to be effective. 30
  • 31. EXAMPLE January 2012  Create a style rule for H1 element with following specifications: Prof. Mukesh N. Tekwani  H1 tag with  Background image: swirlbkg.jpg  Color—green  Letter-spacing-7pt  Text-align- center  Text-decoration-underline  Text-transform--uppercase;  Word-spacing: 2pt 31
  • 32. EXAMPLE(CONTD) January 2012 H1 { Prof. Mukesh N. Tekwani color:green; letter-spacing:7pt; text-align: center; text-decoration:underline; text-transform:uppercase; word-spacing: 2pt } 32
  • 33. EXAMPLE January 2012  Create a style rule for P tag with following specifications: Prof. Mukesh N. Tekwani  Color – magenta  font-family – Algerian  font-size – medium  font-style—italic  font-weight—lighter 33
  • 34. EXAMPLE January 2012 P { Prof. Mukesh N. Tekwani color: magenta; font-family:Algerian; font-size: medium; font-style:italic; font-weight:-lighter; } 34
  • 35. EXAMPLE TO ILLUSTRATE THE VARIOUS STYLES APPLIED TO LISTS: January 2012 <html> <head> Prof. Mukesh N. Tekwani <style type="text/css"> ul.a {list-style-type:circle;} /* open circle */ ul.b {list-style-type:square;} /* filled square */ ul.e {list-style-type:disc;} /* filled circle */ ol.c {list-style-type:upper-roman;} /* upper roman I */ ol.d {list-style-type:lower-alpha;} /* lower alpha: a */ </style> </head> 35
  • 36. LISTS <body> January 2012 <p>Example of unordered lists:</p> <ul class="a"> Prof. Mukesh N. Tekwani <li>Coffee</li> <li>Tea</li> <li>Coca Cola</li> </ul> <ul class="b"> <li>Coffee</li> <li>Tea</li> <li>Coca Cola</li> 36 </ul>
  • 37. LISTS January 2012 <ul class="e"> <li>Coffee</li> <li>Tea</li> Prof. Mukesh N. Tekwani <li>Coca Cola</li> </ul> <p>Example of ordered lists:</p> <ol class="c"> <li>Coffee</li> <li>Tea</li> <li>Coca Cola</li> </ol> </body> </html> 37
  • 38. HANGING INDENT January 2012 Write a style rule for a <P> element with a 24 pt hanging indent and a 30 pixel margin on left and right sides. Prof. Mukesh N. Tekwani <STYLE TYPE = "TEXT/CSS"> P { text-indent:-24pt; margin-left:30px; margin-right:30px } 38 </STYLE>
  • 39. ALIGNING TEXT WITH CSS <html> January 2012 <head> <style> h1 {text-align:center;} Prof. Mukesh N. Tekwani p.date {text-align:right;} p.main {text-align:justify;} </style> </head> <body> <h1>CSS text-align Example</h1> <p class="date">May, 2009</p> <p class="main">In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. 'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'</p> <p><b>Note:</b> Resize the browser window to see how the value "justify" 39 works.</p></body></html>
  • 40. QUESTIONS ? January 2012  Read.  Practice. Prof. Mukesh N. Tekwani  Read.  Practice. : : : 40