<?xml version="1.0"?>
<!DOCTYPE TEI.2 SYSTEM "tei-oucs.dtd"
[ 
 <!NOTATION GRAPHIC SYSTEM ''>
 <!ENTITY pound "&#163;">
 <!ENTITY ldots "&#8230;">
]> 
<TEI.2>
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Cascading style sheets for XML</title>
      </titleStmt>
      <publicationStmt>
        <p> </p>
      </publicationStmt>
      <sourceDesc>
        <p></p>
      </sourceDesc>
    </fileDesc>
    <revisionDesc>
      <list>
        <item><date>July 20th 2001</date>revised</item>
        <item><date>February 5th 2001</date>revised, expanded</item>
        <item><date>November 27th 2000</date>revised</item>
        <item><date>November 21st 2000</date>checked again</item>
        <item><date>June 28th 2000</date>cleaned</item>
        <item><date>June 20th 2000</date>web design class</item>
        <item><date>February 29th 2000</date>web design class</item>
        <item><date>February 12th 2000</date>Edited for talk in Spain</item>
        <item><date>November 11th 1999</date>Started pulling it together</item>
      </list>
    </revisionDesc>
  </teiHeader>
  <text>
<front>
<titlePage>
<docTitle>
 <titlePart type="main">Cascading style sheets for XML</titlePart>
</docTitle>
<docAuthor>Sebastian Rahtz</docAuthor>
<docDate>July 2001</docDate>
</titlePage>
</front>
<body>
<div rend="slide">
<head>Summary</head>
<p>
The purpose of this session is to give a flavour of one of the
family of Web standards, CSS. Others in the group include:
<list type="unordered">
<item> XML: Extensible Markup Language</item>
<item> XSL: Extensible Style Language</item>
<item> DOM: Domain Object Model</item>
<item> XHTML: HTML in XML</item>
<item> MathML: Mathematical Markup Language</item>
<item> SVG: Scaleable Vector Graphics</item>
<item> ...etc ...</item>
</list>
</p>
</div>

<div rend="slide"><head>CSS: why stylesheets?</head>
<list>
<item>To separate form from content</item>
<item>To allow alternate renderers for different classes of readers</item>
<item>To achieve effects not possible in HTML</item>
<item>To provide presentation for XML</item>
<item>To specify consistency across a range of documents</item>
</list>
<p>Note that CSS only supports <emph>embellishment</emph> of HTML or XML, 
   and not serious <emph>transformation</emph>.
</p>
<p>Full details of CSS can be found at <xptr url="http://www.w3.org/Style/CSS/"/>.</p>
</div>

<div rend="slide"><head>CSS support in Web browsers</head>
<p>Very variable!</p>
<list>
<item>There is no 100% reliable CSS renderer</item>
<item>Opera (Windows, Linux and some others) is probably the best</item>
<item>Mozilla / Netscape 6 are good</item>
<item>Internet Explorer 5 is reasonable</item>
<item>Netscape 4 has some serious flaws and does
      not work with XML</item>
</list>
<p>We will mainly cover here features of CSS version 1; version 2
is scantily supported; version 3 is
now being decided on.</p> </div>

<div rend="slide">
<head>A sample of CSS</head>
<p>
<eg>
body {  background: white; 
        margin: 3em;
        }

div2 > head {color: blue; 
        font-style: italic; 
        border-style: dashed;
        border-width: medium; 
        text-align: center;        }

xref  {color: red;}

p {display: block; }
</eg>
</p>
</div>

<div rend="slide"><head>The elements of CSS</head>
<p>
CSS declarations cover five basic types of presentational information,
called <emph>properties</emph>:

<list type="unordered"> 
<item> Foreground and background colors and background images.</item>
<item> Font properties.</item>
<item> Text properties (word spacing, letter spacing, etc.).</item>
<item> Boxes (margins and borders around block elements, floating
elements, etc.).
</item>
<item> Classifications (control over list styles and the formatting of
elements--whether they should be presented inline or displayed as a
block, for example).</item> </list>
</p>
</div>

<div rend="slide">
<head>How do you include your style sheet?</head>
<p>
Style information can be included in a document in several ways:

<list type="unordered"> 

<item> With a style sheet
processing-instruction at the top of an XML 
document:
<eg><![CDATA[<?xml-stylesheet type="text/css"
             href="http://..."?>]]></eg>
</item>
<item> With a style sheet
<code>&lt;LINK></code> in the <code>&lt;HEAD></code> of an XHTML
document:
<eg><![CDATA[<link rel="stylesheet" type="text/css" 
             href="http://...">]]></eg>
</item>
<item>
In the <gi>style</gi> element in the <gi>head</gi> of XHTML
documents.</item>
</list>
</p>
</div>



<div rend="slide"> 
<head>Simple style rule</head> 

<p> A simple style rule has the following form: 
<eg> element-name { property: list } </eg> 
where the element name is anything that appears in your XML file
(<gi>p</gi>, <gi>div</gi>, <gi>emph</gi>
etc.), and the property list is the associated style commands.
<eg>
item { color:red;
     background-color: yellow; 
   }
</eg>
 </p>
</div>



<div rend="slide"> 
<head>Complex style rule</head> 
<p>If you list a series of element names separated by spaces, the rule
applies only to instances of the last element that have all of the
previous ones before them. For example,
<eg>div head emph { color: green }</eg> 
assigns the property to <gi>emph</gi> only if it
occurs inside of an <gi>head</gi> inside of a <gi>div</gi>.
</p>
<p>If you list element names separated by &gt; characters, the elements
must appear <emph>exactly</emph> in that relationship, with
no intervening elements
<eg>body > div > head { font-size: 120%} </eg>
</p>
<p>If you list a series of names separated by commas, the rule applies to 
<emph>all</emph> of them.
<eg>eg, corr, sic { color: blue;} </eg>
</p>
</div>

<div rend="slide">
<head>Pseudo-elements</head>
<p>There is a small, but significant, 
class of <emph>pseudo-elements</emph>, 
which are specified as an element name followed by a colon and 
a <emph>state name</emph>. The possible state names are:
<list type="gloss">
<label>link</label>
<item>When the element is a hypertext link</item>
<label>visited</label>
<item>When the element is a <emph>visited</emph> hypertext link</item>
<label>active</label>
<item>When the element is a link, and being activated</item>
<label>hover</label>
<item>When the element is a link, and the mouse is hovering over it</item>
<label>before</label>
<item>When the processor is about to render an element</item>
<label>after</label>
<item>When the processor has just rendered an element</item>
</list>
    </p>
   </div>
<div rend="slide">
<head>XML example of pseudo-elements</head>
<p>
<eg><![CDATA[gi:before {
  content: "<";
}

gi:after {
  content: ">";
}]]></eg>
This puts &lt; before the content of the <gi>gi</gi> element, and
&gt; afterwards.
    </p>
   </div>

<div rend="slide">
<head>XML example of pseudo-elements (2)</head>
<p>
You can also show the value of attributes,
using the <code>content</code> property
and the <emph>attr</emph> function, as in
<eg>
note[n]:before {
  content: attr(n);
  vertical-align: super;
}
</eg>
which says that if a <gi>note</gi> element has an `n' attribute, we
want to put the value of that attribute, superscripted, before the element
content.
</p>
</div>
<!--
<div rend="slide">
<head>Subclassing elements (HTML)</head>
<p>
Sometimes you want to treat specific instances of an element
differently.  You can use the <code>class</code> attribute, which can be
placed on any element to assign a specific role to an element. For
example
<eg><![CDATA[<p class="warning">
<a class="offsite" href="http://...">...</a>]]></eg>
To specify the styles for elements of a particular class, add the class
name to the element name with a period in the style sheet:
<eg>p.warning { properties }
a.offsite { properties }</eg>
</p>
</div>
-->

<div rend="slide">
<head>Subclassing by attribute value</head>
<p>
You can narrow down the effect of a rule by specifying attribute values in
square brackets after the element name:
<eg>
hi[rend='bold']   { font-weight: bold;} 
hi[rend='italic'] { font-style: italic ;} 
</eg>
</p>
</div>

<div rend="slide">
<head>Subclassing by ID</head>
<p>
Another form of subclassing is by ID. This is the mechanism that allows
you to avoid embedding specific style information in your document even
for a unique element. If you have a specific element that must be uniquely
treated, you can give it an ID:
<eg><![CDATA[<p id="special-case">]]></eg>
and then assign style information to that element with a <code>#</code>:

<eg>
#special-case { properties }
</eg>
Note that IDs are <emph>required</emph> to be unique within a document. This
requirement may not be enforced by current browsers, but it is a requirement
for a truly conforming document. 
</p>
</div>

<div rend="slide">
<head>Foreground and background colors</head> 
<p>There are two
properties for specifying colors: <code>color</code> and
<code>background</code>. The <code>color</code> property controls the
foreground color of an element. Usually this is the color of the text
of an element. Colors may be identified either by name or by RGB
value.
</p>
<p>The <code>background</code> property controls the background color or 
texture of an element. When an image is specified for use as a texture, its position,
scrolling aspect, and repeatability can be controlled.</p>
</div>

<div>
<head>The normal set of colors</head>
<p><table>
<row>
<cell>&#160;</cell>
<cell>Name</cell>
<cell>Percent</cell>
<cell>Integer</cell>
<cell>Hexidecimal</cell>
<cell>&#160;</cell>
</row>

<row>
<cell rend="#00FFFF">&#160;</cell>
<cell>aqua</cell>
<cell>rgb(0%,100%,100%)</cell>
<cell>rgb(0,255,255)</cell>
<cell>#00FFFF</cell>
<cell>#0FF</cell>
</row>

<row>
<cell rend="#000000">&#160;</cell>
<cell>black</cell>
<cell>rgb(0%,0%,0%)</cell>
<cell>rgb(0,0,0)</cell>
<cell>#000000</cell>
<cell>#000</cell>
</row>

<row>
<cell rend="#0000FF">&#160;</cell>
<cell>blue</cell>
<cell>rgb(0%,0%,100%)</cell>
<cell>rgb(0,0,255)</cell>
<cell>#0000FF</cell>
<cell>#00F</cell>
</row>

<row>
<cell rend="#FF00FF">&#160;</cell>
<cell>fuschia</cell>
<cell>rgb(100%,0%,100%)</cell>
<cell>rgb(255,0,255)</cell>
<cell>#FF00FF</cell>
<cell>#F0F</cell>
</row>

<row>
<cell rend="#808080">&#160;</cell>
<cell>gray</cell>
<cell>rgb(50%,50%,50%)</cell>
<cell>rgb(128,128,128)</cell>
<cell>#808080</cell>
<cell>#888</cell>
</row>

<row>
<cell rend="#008000">&#160;</cell>
<cell>green</cell>
<cell>rgb(0%,50%,0%)</cell>
<cell>rgb(0,128,0)</cell>
<cell>#008000</cell>
<cell>#080</cell>
</row>

<row>
<cell rend="#00FF00"> </cell>
<cell>lime</cell>
<cell>rgb(0%,100%,0%)</cell>
<cell>rgb(0,255,0)</cell>
<cell>#00FF00</cell>
<cell>#0F0</cell>
</row>

<row>
<cell rend="#800000">&#160;</cell>
<cell>maroon</cell>
<cell>rgb(50%,0%,0%)</cell>
<cell>rgb(128,0,0)</cell>
<cell>#800000</cell>
<cell>#800</cell>
</row>

<row>
<cell rend="#000080">&#160;</cell>
<cell>navy</cell>
<cell>rgb(0%,0%,50%)</cell>
<cell>rgb(0,0,128)</cell>
<cell>#000080</cell>
<cell>#008</cell>
</row>

<row>
<cell rend="#808000">&#160;</cell>
<cell>olive</cell>
<cell>rgb(50%,50%,0%)</cell>
<cell>rgb(128,128,0)</cell>
<cell>#808000</cell>
<cell>#880</cell>
</row>

<row>
<cell rend="#800080">&#160;</cell>
<cell>purple</cell>
<cell>rgb(50%,0%,50%)</cell>
<cell>rgb(128,0,128)</cell>
<cell>#800080</cell>
<cell>#808</cell>
</row>

<row>
<cell rend="#FF0000">&#160;</cell>
<cell>red</cell>
<cell>rgb(100%,0%,0%)</cell>
<cell>rgb(255,0,0)</cell>
<cell>#FF0000</cell>
<cell>#F00</cell>
</row>

<row>
<cell rend="#C0C0C0">&#160;</cell>
<cell>silver</cell>
<cell>rgb(75%,75%,75%)</cell>
<cell>rgb(192,192,192)</cell>
<cell>#C0C0C0</cell>
<cell>#BBB</cell>
</row>

<row>
<cell rend="#008080">&#160;</cell>
<cell>teal</cell>
<cell>rgb(0%,50%,50%)</cell>
<cell>rgb(0,128,128)</cell>
<cell>#008080</cell>
<cell>#088</cell>
</row>

<row>
<cell rend="#FFFFFF">&#160;</cell>
<cell>white</cell>
<cell>rgb(100%,100%,100%)</cell>
<cell>rgb(255,255,255)</cell>
<cell>#FFFFFF</cell>
<cell>#FFF</cell>
</row>

<row>
<cell rend="#FFFF00">&#160;</cell>
<cell>yellow</cell>
<cell>rgb(100%,100%,0%)</cell>
<cell>rgb(255,255,0)</cell>
<cell>#FFFF00</cell>
<cell>#FF0</cell>
</row>
</table></p>
</div>

<div rend="slide">
<head>Font properties</head>

<p>There are five properties that control which fonts are used:</p>
<list type="gloss">

<label><code>font-family</code></label>
<item> Identifies the font family, or
typeface, to use. A series of names may be requested; the first
available font will be used. There are five classes of "generic" fonts
that may be specified as a last resort, <code>serif</code> for serifed
faces like Times Roman; <code>sans-serif</code> for san-serif faces
like Helvetica; <code>monospace</code> for fixed-width fonts like
Courier; <code>cursive</code> for swash faces like Zapf Chancery, and
<code>fantasy</code> for other hard-to-classify faces like Grunge or
Western.</item>
</list>
</div>

<div rend="slide">
<head>Font properties (2)</head>
<list type="gloss">
<label>
<code>font-style</code>
</label>
<item>
Identifies the style of the face, <code>normal</code>, <code>italic</code>,
or <code>oblique</code>.
</item>

<label>
<code>font-variant</code>
</label>
<item>
Identifies another variation on the face, either <code>normal</code> or
<code>small-caps</code> in CSS1.
</item>

<label>
<code>font-size</code>
</label>
<item>
The size of the face. Font size may be specified in absolute units (eg
	    <code>10pt</code>) or
relative to the `current' size (eg <code>120%</code>)
</item>

<label> <code>font-weight</code> </label> 
<item> The weight or
boldness of the font, specified with either a keyword
(<code>bold</code> or <code>bolder</code>, for example) or as a member
of the ordered series 100, 200, 300, . . . , 900, where higher numbers
are correspondingly darker.  </item> 
</list> 
</div>

<div rend="slide">
<head>Text properties</head>
<p>Several text properties are available:</p>
<list type="gloss">
<label><code>word-spacing</code></label>
<item>
Modifies the default inter-word spacing.
</item>

<label>
<code>letter-spacing</code>
</label>
<item>
Modifies the default inter-letter spacing.
</item>

<label>
<code>text-decoration</code>
</label>
<item>
Choices are <code>underline</code>, <code>overline</code>, 
<code>line-through</code>, <code>blink</code> or <code>none></code>.
</item>
<label>
<code>text-transform</code>
</label>
<item>
Shifts text to uppercase or lowercase, with values
<code>capitalize</code>,  <code>uppercase</code>,
	    <code>lowercase</code> or <code>none</code>.
</item>
</list>
</div>

<div rend="slide">
<head>Text properties (2)</head>
<list type="gloss">

<label>
<code>text-align</code>
</label>
<item>
Specifies alingment as
<code>left</code>, <code>right</code>, <code>center</code> or <code>justify</code>.
</item>

<label>
<code>text-indent</code>
</label>
<item>
Determines the amount of indentation on the first line of a block of
text.
</item>

<label>
<code>line-height</code>
</label>
<item>
Specifies the distance between the baselines of consecutive lines of
text.
</item>
</list>
</div>

<div rend="slide">
<head>Text properties (3)</head>
<list type="gloss">

<label>
<code>vertical-align</code>
</label>
<item>
Adjusts the vertical alignment of an element.
Possible values are 
<list type="gloss">
<label>baseline</label>
<item> align the baseline of the element (or the bottom, if the
element doesn't have a baseline) with the baseline of the parent
</item>

<label>middle</label> <item> align the vertical midpoint of the
element (typically an image) with the baseline plus half the x-height
of the parent </item>

<label>sub</label>
<item> subscript the element </item>

<label>super</label>
<item> superscript the element </item>

<label>text-top</label>
<item> align the top of the element with the top of the parent element's font </item>

<label>text-bottom</label> <item> align the bottom of the element with
the bottom of the parent element's font</item>
</list>
</item>

</list>
</div>

<div rend="slide">
<head>Boxes</head>
<p>
Each element has a margin, inside the margin is an optional border, inside
the border is optional padding, and inside the padding is the actual 
formatted content of the element. The box properties allow you to 
determine how the content of the element is formatted
to fit in the space provided.
<figure  rend="inline" width="5in" file="cssbox"/>

</p>
</div>

<div rend="slide">
<head>Boxes (2)</head>
<list type="gloss">
<label><code>margin</code></label>
<item>(<code>margin-bottom</code>, <code>margin-top</code>,
<code>margin-left</code>, <code>margin-right</code>)
Determine the size of the top, bottom, left, and right margins. Setting
<code>margin</code> adjusts all of the margins simultaneously.
</item>

<label>
<code>padding</code></label>
<item>(<code>padding-bottom</code>, <code>padding-top</code>,
<code>padding-left</code>, <code>padding-right</code>)
Adjusts the amount of padding on the top, bottom, left, and right sides
of the element. 
Setting <code>padding</code> adjusts all of them simultaneously.
</item>
    </list>
</div>

<div rend="slide">
<head>Boxes (3)</head>
<list type="gloss">

<label>
<code>border</code></label>
<item>(<code>border-top</code>, <code>border-bottom,</code>
<code>border-left</code>, <code>border-right</code>)
Selects the nature of the border on the top, bottom, left, and right
sides of the element. 
Setting <code>border</code> adjusts all of borders simultaneously.
You can specify the <code>-width</code>, <code>-color</code>, and 
<code>-style</code> of the border. ie
<eg>
	border-top-style: solid;
	border-bottom-width: 12pt;
	border-left-color: black;
</eg>

</item>
    </list>
</div>

<div rend="slide">
<head>Boxes (4)</head>
<list type="gloss">
<label>
<code>width</code>, <code>height</code>
</label>
<item>
Identifies the width and height of the rectangle that contains the
formatted content. Images should be scaled to the specified size, if necessary.
</item>

<label>
<code>float</code>
</label>
<item>
Identifies an element that should float to the left or right of a flow
of text, allowing the text to flow around it.
</item>

<label>
<code>clear</code>
</label>
<item>
Specifies where floating elements may occur with respect to the element.
For example, specifying <code>clear: left</code> indicates that there
may be no floating elements to the left of the element; this will force
the element to start below an image floating on the left side of the display,
for example.
</item>
</list>
</div>

<div rend="slide">
<head>Classifications</head>
<p>
There are three classification properties, <code>display</code>,
<code>list-style</code>, and <code>white-space</code>:
</p>
<list type="gloss">
<label><code>display</code></label>
<item>
Allows you to specify what category of object an element belongs to:
ie a block element, like a heading or paragraph
(<emph>block</emph>); an inline element,
like emphasis or anchors
(<emph>inline</emph>); or a list-item block element, like
TEI <gi>item</gi> (<emph>list-item</emph>).
An additional category is <emph>none</emph>, which indicates that the content
of the element should not be displayed at all.
</item>
</list>
</div>

<div rend="slide">
<head>Classifications (2)</head>
<list type="gloss">

<label><code>list-style</code></label>
<item>
Influences the selection of numbers or bullets for lists. In addition
to selecting one of the built-in enumeration or bullet styles, you can
specify an image for use as the bullet character. You can also influence
the position of the list mark with respect to the flow of the text. An
<code>outside</code> list mark occurs to the left of the entire list item,
whereas text wraps under an <code>inside</code> mark.
</item>

<label><code>white-space</code></label>
<item>
Identifies how the line breaking of an element is to be accomplished.
Possible values are <code>normal</code>; <code>pre</code>, where all
white space is significant; and <code>nowrap</code> where white space
serves primarily as a delimiter, but no wrapping is done.
</item>
</list>
</div>

<div rend="slide">
<head>An example XML TEI stylesheet</head>
<eg>
body
{
  font-family: "Times New Roman";
  font-size: 12pt;
  margin-top: 5px;
  margin-left: 5px;
}

emph {
  display: inline;
  font-style: italic;
}

hi {
  font-weight: bold;
}

p {display: block}
    </eg>
</div>

<div rend="slide">
<head>An example XML TEI stylesheet (part 2)</head>
<eg>
item {
  display: list-item;
  margin-left: 12pt;
}

list[type="bulleted"] {
  list-style-type: disc;
  list-style-position: outside;
}

list[type="ordered"] {
  list-style-type: decimal;
  list-style-position: outside;
}

</eg>
</div>

</body>
</text>
</TEI.2>
