HTML, CSS, and DOM

Mobile Application Design and Development [./]
Spring 2010 — INFO 152 (CCN 42504)

Erik Wilde, UC Berkeley School of Information
2010-02-01

Creative Commons License [http://creativecommons.org/licenses/by/3.0/]

This work is licensed under a CC
Attribution 3.0 Unported License
[http://creativecommons.org/licenses/by/3.0/]

Contents Erik Wilde: HTML, CSS, and DOM

Contents

Erik Wilde: HTML, CSS, and DOM

(2) Abstract

The Hypertext Markup Language (HTML) is the most important content type on the Web. Modern browsers are expected to support HTML, CSS for styling the content of a HTML page, and scripting so that server-supplied scripting code can run in the browser, update the HTML and/or CSS, and interact with the user or the browser. This lecture presents an overview of how the building blocks of HTML, CSS, DOM, and scripting fit together to provide Web applications with a standardized and robust platform.



Hypertext Markup Language (HTML)

Outline (Hypertext Markup Language (HTML))

  1. Hypertext Markup Language (HTML) [5]
  2. Cascading Style Sheets (CSS) [7]
  3. Document Object Model (DOM) [7]
Hypertext Markup Language (HTML) Erik Wilde: HTML, CSS, and DOM

(4) HTML Definition

<!-- Unordered Lists (UL) bullet styles -->
<!ELEMENT UL - - (LI)+                 -- unordered list -->
<!ATTLIST UL
  %attrs;                              -- %coreattrs, %i18n, %events --
  >
<!ELEMENT LI - O (%flow;)*             -- list item -->
<!ATTLIST LI
  %attrs;                              -- %coreattrs, %i18n, %events --
  >
<!ENTITY % flow "%block; | %inline;">
<!ENTITY % block
     "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
      BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">


Hypertext Markup Language (HTML) Erik Wilde: HTML, CSS, and DOM

(5) HTML Validation



Hypertext Markup Language (HTML) Erik Wilde: HTML, CSS, and DOM

(6) HTML and WYSIWYG



Hypertext Markup Language (HTML) Erik Wilde: HTML, CSS, and DOM

(7) Web Browsers

Web Browser Usage

██ Internet Explorer (59.21%)

██ Mozilla Firefox (28.29%)

██ Chrome (5.02%)

██ Safari (4.54%)

██ Opera (1.68%)

██ Other (1.26%)



Hypertext Markup Language (HTML) Erik Wilde: HTML, CSS, and DOM

(8) Web Browser History

Web Browser History

Cascading Style Sheets (CSS)

Outline (Cascading Style Sheets (CSS))

  1. Hypertext Markup Language (HTML) [5]
  2. Cascading Style Sheets (CSS) [7]
  3. Document Object Model (DOM) [7]
Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(10) CSS in Action

<body id="css-zen-garden">
<div id="container">
 <div id="intro">
  <div id="pageHeader">
   <h1><span>css Zen Garden</span></h1>
   <h2><span>The Beauty of <acronym title="Cascading Style Sheets">CSS</acronym> Design</span></h2>
  </div>
  <div id="quickSummary">
   <p class="p1"><span>A demonstration of what can be accomplished visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p>
   <p class="p2"><span>Download the sample <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p>
  </div>
  <div id="preamble">
   <h3><span>The Road to Enlightenment</span></h3>
   <p class="p1"><span>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible <acronym title="Document Object Model">DOM</acronym>s, and broken <acronym title="Cascading Style Sheets">CSS</acronym> support.</span></p>


Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(11) HTML and CSS

 <head>
  <title>CSS Usage</title>
  <link href="http://dret.net/dretnet.css" rel="stylesheet" type="text/css"/>
  <style type="text/css"> li { color : red } </style>
 </head>
 <body>
  <p>some text in a paragraph..</p>
  <ol>
   <li>an ordered list's first item</li>
   <li style=" text-decoration : underline ">and the second one</li>
  </ol>


Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(12) Formatting Model



Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(13) CSS Properties



Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(14) CSS Selectors



Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(15) Cascading



Cascading Style Sheets (CSS) Erik Wilde: HTML, CSS, and DOM

(16) Inheritance



Document Object Model (DOM)

Outline (Document Object Model (DOM))

  1. Hypertext Markup Language (HTML) [5]
  2. Cascading Style Sheets (CSS) [7]
  3. Document Object Model (DOM) [7]
Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(18) From HTML to DOM



Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(19) Browser Handling of HTML

Browser Handling of HTML

Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(20) Document



Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(21) Object

    for (var ti=0;ti<document.links.length;ti++) {
        var lnk = document.links[ti];
        if ( lnk.title ) {
            lnk.setAttribute("nicetitle",lnk.title);
            lnk.removeAttribute("title");
            addEvent(lnk,"mouseover",showNiceTitle);
            addEvent(lnk,"mouseout",hideNiceTitle);
            addEvent(lnk,"focus",showNiceTitle);
            addEvent(lnk,"blur",hideNiceTitle);
        }
    }


Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(22) Model



Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(23) Markup to Trees



Document Object Model (DOM) Erik Wilde: HTML, CSS, and DOM

(24) DOM History



2010-02-01 Mobile Application Design and Development [./]
Spring 2010 — INFO 152 (CCN 42504)