HTML – Hypertext Markup Language
Computer Science and Engineering n College of Engineering n The Ohio State University
Lecture 9 HTML
Computer Science and Engineering n The Ohio State University o Hypertext Markup Language o Key ideas: 1. Connect documents via (hyper)links o Visual point-and-click o Distributed, decentralized set of documents 2. Describe content of document, not style o Structure with semantics o Separation of concerns o Rephrasing these key ideas: 1. Hypertext 2. Markup Markup: Describing Content
Computer Science and Engineering n The Ohio State University o WYSIWYG n A paragraph or bulleted list in MS Word n Benefits: o No surprises in final appearance o Quick and easy o Control: Author can use visual elements to stand in for structural elements o WYSIWYM n A paragraph or list in LaTeX n Benefits: o More information in document (visual & semantic) o Lack of Control: Author doesn't know how to apply visual elements properly for structure Abstraction vs Representation
Computer Science and Engineering n The Ohio State University
\section{To Do List} \begin{enumerate} \item{Study for midterm} \item{Sleep} \end{enumerate} Authors Lack Requisite Expertise
Computer Science and Engineering n The Ohio State University o What's wrong with the following page?
Chapter 9
Now that we have the ability to display a catalog containing all our wonderful products, it would be nice to be able to sell them. We will need to cover sessions, models, and adding a button to a view. So let's get started.
Iteration D1: Finding a Cart … Evolution of HTML
Computer Science and Engineering n The Ohio State University o HTML (Berners-Lee, early 90's) o HTML 2.0 (W3C, '95) o HTML 3.2 (W3C, '97) o HTML 4.0 (W3C, '97) n To form a more perfect union… o HTML 4.01 (W3C, '99) n To smooth out the edges… big dog for years o The great schism n W3C: XHTML 1.0 ('00), 1.1 ('01), 2.0 n Everyone else: HTML Forms, WHAT… o Capitulation ('09): W3C abandons XHTML 2.0 o HTML5 (October 2014) n One ring to rule them all… n (includes XHTML5, but no one seems to care) Page Validation
Computer Science and Engineering n The Ohio State University o Design-by-contract: n Strong ensures, weak requires n Be strict in output, permissive in input o Browsers (taking HTML as input) are permissive n "Tag soup" still renders o Web authors (writing HTML as output) should be as strict as possible n But permissive browsers hide errors! o Solution: use a validator n See validator.w3.org n Checks for syntax problems only Example
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University o HTML 5 o HTML 4.01 o XHTML 1.0 Strict Type Declaration for HTML 5
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University
html lang: en element attr name: attr value head body content
title meta p charset: utf-8
Hello a ! br img href: planet.html src: pic.png ald: a globe Something Short World and Sweet Attributes: Name/Value Pairs
Computer Science and Engineering n The Ohio State University
Hello World!
Computer Science and Engineering n The Ohio State University
html lang: en element attr name: attr value head body text
title meta p charset: utf-8
Hello a ! br img href: planet.html src: pic.png alt: a globe Something Short World and Sweet HTML Entities
Computer Science and Engineering n The Ohio State University o Familiar problem: Encoding n Is
a tag or (literal) content? n Meta-characters (e.g. '<') need to be escaped o HTML entities represent a literal dddd; n Where dddd is the "unicode code point" (as a decimal number) hhhh; n Where hhhh is the code point in hex &name; n Where name is from a small set (lt, gt, amp…) o Examples: < < < ♥ ♥ ♥ Kinds of Elements
Computer Science and Engineering n The Ohio State University 1. Document structure elements n Root of tree is always n Two children:
, 2. Head elements n (Meta) information about document 3. Body elements 1. Block o Content that stands alone o Starts new line of text o May contain other elements (block or inline) 2. Inline o Intimately part of surrounding context o Does not interrupt "flow" of text o May contain other inline elements Block vs InlineComputer Science and Engineering n The Ohio State University
flow body inline paragraph
heading
horz rule blocks Demo: 3D View in FF Dev Tools
Computer Science and Engineering n The Ohio State University Required Structure for HTML5
Computer Science and Engineering n The Ohio State University
html lang: en element attr name: attr value head body text
title meta charset: utf-8 Common Head Elements
Computer Science and Engineering n The Ohio State University o