<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../../_utils/schema/yaps.rnc" type="application/relax-ng-compact-syntax"?>
<?xml-model href="../../../_utils/schema/yaps.isosch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-stylesheet type="text/xsl" href="yaps2slidy1.xslt"?>
<!-- $Id: mdh_css-for-xhtml-intro.xml 51709 2026-05-28 23:29:13Z syd $ -->
<TEI xmlns="http://www.wwp.northeastern.edu/ns/yaps" version="5.0">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Using CSS with XHTML</title>
        <author>Martin Holmes</author>
      </titleStmt>
      <editionStmt>
        <edition>Brown University</edition>
      </editionStmt>
      <publicationStmt>
        <distributor>Women Writers Project (via website)</distributor>
        <address>
          <addrLine>url:mailto:wwp@northeastern.edu</addrLine>
        </address>
        <date when="2011-07-21"/>
      </publicationStmt>
      <sourceDesc>
          <p>Born digital</p>
      </sourceDesc>
    </fileDesc>
    <revisionDesc>
      <change when="2011-07-18" who="sdb">Various minor tweaks, mostly phrase-level encoding.</change>
      <change when="2011-03-29" who="mdh">Added markup for elements, attributes and values.</change>
      <change when="2011-03-22" who="mdh">Began writing this file.</change>
    </revisionDesc>
  </teiHeader>
  <text>
    <presentation>

      <section>
        <head>Using CSS with XHTML</head>
        <slide>
          <list>
            <item>You know how to write XSLT stylesheets to transform XML into XHTML.</item>
            <item>But now you have XHTML, how do you style it?</item>
            <item>Cascading Style Sheets (CSS) are the answer.</item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>What is CSS?</head>
        <slide>
          <list>
            <item>Simple, declarative syntax for positioning, styling, colouring and outlining things.</item>
            <item>Very human-readable: <eg><![CDATA[font-style: italic;]]></eg> means exactly what you would expect.</item>
            <item>Very powerful and rich, especially recent 2.1 and 3.0 versions.</item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>Getting started: how to link your XHTML file to a CSS file</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/link_xhtml_to_css.png" width="800px" height="569px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>The <gi>link</gi> element</head>
        <slide>
          <egMarkup scheme="XHTML" type="valid">
            <link rel="stylesheet"
                       type="text/css"
                       href="myStyle.css" />
          </egMarkup>
        </slide>
      </section>
      
      <section>
        <head>CSS Rulesets (1)</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/css_ruleset_01.png" width="780px" height="610px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>CSS Rulesets (2): Selector</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/css_ruleset_02.png" width="780px" height="610px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>CSS Rulesets (3): Property</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/css_ruleset_03.png" width="780px" height="610px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>CSS Rulesets (4): Value</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/css_ruleset_04.png" width="780px" height="610px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>CSS Rulesets (5): Punctuation</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/css_ruleset_05.png" width="780px" height="610px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>CSS Rulesets (6): Summary</head>
        <slide>
          <figure><graphic url="../../../_utils/gfx/css_ruleset_06.png" width="780px" height="610px"/></figure>
        </slide>
      </section>
      
      <section>
        <head>CSS Selectors (1)</head>
        <slide>
          <list type="incremental">
            <item><eg><![CDATA[h1]]></eg> Select by element name (<tag>h1</tag>)</item>
            <item><eg><![CDATA[span.placeName]]></eg> Select by element and class, using a dot (<tag>span class="placeName"</tag>)</item>
            <item><eg><![CDATA[p span.placeName]]></eg> Select by descendant: all <tag>span class="placeName"</tag> elements inside a <tag>p</tag> element</item>
            <item><eg><![CDATA[h2 > span.bookTitle]]></eg> Select by child using <q><code>&gt;</code></q>: all <tag>span class="bookTitle"</tag> elements which are direct children of an <tag>h2</tag> element</item>
            <item><eg><![CDATA[h2#mainTitle]]></eg> Select by id (<tag>h2 id="mainTitle"</tag>)</item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS Selectors (2)</head>
        <slide>
          <list type="incremental">
            <item><eg><![CDATA[.placeName]]></eg> Select by class, using a dot (any element with <code>class="placeName"</code>)</item>
            <item><eg><![CDATA[#subTitle]]></eg> Select by ID (without needing to specify the element name)</item>      
            <item><eg><![CDATA[h1, h2, h3.chapterTitle]]></eg> Group several selectors together, comma-separated (<tag>h1</tag>, <tag>h2</tag>, <tag>h3 class="chapterTitle"</tag>)</item>
          </list>
        </slide>
      </section>
      
        <section>
          <head>CSS Selectors: Task</head>
          <slide>
              <p>How would you write a selector for:</p>
            <list>
              <item><emph>both <gi>p</gi> and <gi>blockquote</gi> elements</emph>?</item>
              <item><emph>a <gi>div</gi> element with <att>id</att> <val>notes</val></emph>?</item>
              <item><emph>a <gi>p</gi> with a <att>class</att> of
              <val>intro</val> which is inside a <gi>div</gi> with a
              <att>class</att> of <val>front</val></emph>?</item>
            </list>
            </slide>
        </section>
      
      <section>
        <head>CSS Selectors: Task answer 1</head>
        <slide>
          <p>How would you write a selector for:</p>
          <list>
            <item><emph>both <gi>p</gi> and <gi>blockquote</gi> elements</emph>?</item>
            <item><eg><![CDATA[p, blockquote { ... }]]></eg></item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS Selectors: Task answer 2</head>
        <slide>
          <p>How would you write a selector for:</p>
          <list>
            <item><emph>a <gi>div</gi> element with <att>id</att> <val>notes</val></emph>?</item>
            <item><eg><![CDATA[div#notes { ... }]]></eg></item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS Selectors: Task answer 3</head>
        <slide>
          <p>How would you write a selector for:</p>
          <list>
            <item><emph>a <gi>p</gi> with a <att>class</att> of
            <val>intro</val> which is inside a <gi>div</gi> with a
            <att>class</att> of <val>front</val></emph>?</item>
	    <item><eg><![CDATA[div.front p.intro { ... }]]></eg></item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS Units</head>
        <slide>
          <list>
            <item>CSS property values which involve measurement can be expressed in several different units:</item>
            <item>Physical measurements: <emph>in, cm, mm, pt, pc</emph> (caution)</item>
            <item>Screen-related units: <emph>px</emph> (don't use)</item>
            <item>Relative units: <emph>em, ex, %</emph> (the best options)</item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS Box model</head>
        <slide>
          <p>This is how padding, margins, borders etc, work for block elements in CSS:</p>
          <figure><graphic url="../../../_utils/gfx/css_box_model.png" width="800px" height="461px"/></figure>
          <bibl>(Image courtesy of Felix.leg/Wikimedia)</bibl>
        </slide>
      </section>
      
      <section>
        <head>CSS Properties</head>
        <slide>
          <list>
            <item>Too many to list exhaustively</item>
            <item>Lots of useful references on the web (e.g. <ref target="http://www.w3schools.com/css/">http://www.w3schools.com/css/</ref>)</item>
            <item>Browse the references for ideas</item>
            <item>Figure out what you want to do and then Google, ask, read specs, etc.</item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS: A detailed example</head>
        <slide>
          <eg><![CDATA[
            div.warningBox{
              border: solid 2px black;
              background-color: white;
              color: red;
              margin: 1em;
              text-align: center;
              font-weight: bold;
              line-height: 150%;
            }
          ]]></eg>
          
        </slide>
      </section>
      
      <section>
        <head>CSS: Task</head>
        <slide>
          <p>Write a ruleset that:</p>
          <list>
            <item>applies to all paragraphs which are children of a
            <gi>div</gi> with an <att>id</att> of
            <val>afterword</val></item>
            <item>indents the first line of the paragraph by 1 em</item>
            <item>justifies the paragraph</item>
            <item>sets a font size which is twice as big as the default</item>
            <item>draws a dotted border around the paragraph</item>
            <item>leaves a space of 2 ems between the border and the text</item>
          </list>
        </slide>
      </section>
      
      <section>
        <head>CSS: Task answer</head>
        <slide>
          <eg><![CDATA[
            div#afterword p{
              text-indent: 1em;
              text-align: justify;
              font-size: 200%;
              border-width: 1px;
              border-style: dotted;
              padding: 2em;
            }
          ]]></eg>
        </slide>
      </section>
      
    </presentation>
  </text>
</TEI>
