Professional Documents
Culture Documents
1. Introduction
A web page has structure
HTML5
And interaction
JavaScript
28/09/2012
1. Introduction
Use of HTML5 to structure the page Elements include:
header, nav, article, section, aside, footer, div
Search facility
1. Introduction
The appearance of the website can be controlled using a stylesheet
Cascading Style Sheets (CSS) is used for Web documents
banner navbar
There are also elements for headings, paragraphs, tables, figures, spans, And more advanced features
canvas, video, audio,
main content
with other areas, e.g. links
With footer
Without
28/09/2012
28/09/2012
1. Introduction
And interaction: JavaScript
Example: move the figures on the page Moving balls HTML5 games canvas and JavaScript
28/09/2012
28/09/2012
Structure: HTML
Appearance: CSS
h1 { color: teal; font-family: Georgia, serif; font-size: 200%; } p { color: blue; } ul { padding-left: 100px; list-style-type: circle; } li { color: #123456; }
<head> <meta charset="utf-8" /> <title>Team X</title> <!-- add stylesheet link --> </head> <body> <h1>Team X</h1> <p>We are Team X.</p> <ul> <li>Art</li> <li><a href="h t t p : / / w w w . t h e s i m p s o n s . c o m / ">Bart</a> </ l i> <li>Cara</li> </ul> </body> </html>
Annotate a document to, for example, show its structure eXtensible Markup Language (XML)
Strict set of rules for defining the encoding a document or an arbitrary data structure
http://en.wikipedia.org/wiki/File:RecipeBook_XML_Example.png
teamx1.html
Dr Steve Maddock, The University of Sheffield
teamx1.css
28/09/2012 Dr Steve Maddock and Dr Mike Stannett, The University of Sheffield
10
p.109, Chapman, N and J. Chapman, Web Design: A complete introduction, John Wiley & Sons, 2006.
28/09/2012 Dr Steve Maddock, The University of Sheffield 28/09/2012 Dr Steve Maddock, The University of Sheffield
11
12
4. HTML Markup
A general document is made up of elements
start mix of text and tag elements <??> matching end tag </??>
4. HTML Markup
<body> <h1>Team X</h1> <p>We are Team X.</p> <ul> <li>Art</li> <li><a href="http://www.thesimpsons.com/">Bart</a></li> <li>Cara</li> </ul> </body>
<body> Can also have empty elements, e.g. <br /> <h1>Team X</h1> <p>We are Team X.</p> <ul> <li>Art</li> <li><a href="http://www.thesimpsons.com/">Bart</a></li> <li>Cara</li> </ul> </body>
28/09/2012
13
14
5. Hyperlinks
The ends of hyperlinks are called anchors
They link a source and a destination <a href="URL">link text</a>
From within
<a href="../feedback.html">feedback</a>
Default display: blue and underlined Once visited: purple and underlined
<body> <h1>Team X</h1> Uses an absolute URL <p>We are Team X.</p> <ul> <li>Art</li> <li><a href="http://www.thesimpsons.com/">Bart</a></li> <li>Cara</li> </ul> </body>
28/09/2012
15
16
Structure: HTML
Appearance: CSS
h1 { color: teal; font-family: Georgia, serif; font-size: 200%; } p { color: blue; } ul { padding-left: 100px; list-style-type: circle; } li { color: #123456; }
<head> <meta charset="utf-8" /> <title>Team X</title> <!-- add stylesheet link --> </head> <body> <h1>Team X</h1> <p>We are Team X.</p> <ul> <li>Art</li> <li><a href="h t t p : / / w w w . t h e s i m p s o n s . c o m / ">Bart</a> </ l i> <li>Cara</li> </ul> </body> </html>
teamx1.html
Dr Steve Maddock, The University of Sheffield
teamx1.css
17
18
<!--
-->
A comment
DTD Strict
Modern Web browsers have the DTD incorporated into their code.
Public Identifier -//W3C//DTD XHTML 1.0 Strict//EN -//W3C//DTD XHTML 1.0 Transitional//EN URL http://www.w3.org/TR/xhtml1/DTD/ xhtml1-strict.dtd http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd
en means English <HTML lang="fr"> <HEAD> <TITLE>Un document multilingue</TITLE> </HEAD> www.w3.org/TR/html4/struct/dirlang.html
28/09/2012 Dr Steve Maddock, The University of Sheffield
Transitional
Frameset
http://www.w3.org/TR/xhtml1/DTD/ xhtml1-frameset.dtd
28/09/2012
19
20
Other meta data elements use name and content attributes Other elements
link stylesheets (see later in this lecture) script JavaScript (see a later lecture)
<!--
-->
<head> <meta charset="utf-8" /> <title>Team X</title> <link rel="stylesheet" href="teamx1.css" /> <meta name="author" content="Steve Maddock" /> <meta name="description" content="Team X web site for COM1004" /> <meta name="keywords" content="Team X, sports" /> </head>
28/09/2012
21
html
22
7. Document structure
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Team X</title> </head> head body
title
h1
p ul
ul ul ul
metadata
Chapman, N and J. Chapman, Web Design: A complete introduction, John Wiley & Sons, 2006.
<body> a <h1>Team X</h1> <p>We are Team X.</p> content <ul> <li>Art</li> <li><a href="http://www.thesimpsons.com/">Bart</a></li> <li>Cara</li> </ul> </body> </html>
28/09/2012
28/09/2012
23
24
7.1 Layout
<body> <h1>Team X</h1> Indent 2 spaces <p>We are Team X.</p> <ul> <li>Art</li> <li><a href="http://www.thesimpsons.com/">Bart</a></li> <li>Cara</li> </ul> </body> <body> <h1>Team X</h1> <p>We are Team X.</p> Indent 4 spaces <ul> <li>Art</li> <li><a href="http://www.thesimpsons.com/">Bart</a></li> <li>Cara</li> </ul> </body>
Dr Steve Maddock, The University of Sheffield
8. Appearance
A browser (sometimes called a User Agent) has defaults for the appearance of each element A browser can offer the user options to override these defaults Alternative: Glue a stylesheet
Some editors will layout the code for you There are also tools to tidy up your HTML, e.g. HTML Tidy (http://inf ohound.n et/tidy/)
28/09/2012
28/09/2012
25
26
teamx1.html
Dr Steve Maddock, The University of Sheffield
27
28
h1 { color: teal; font-family: Georgia, serif; font-size: 200%; } p{ color: blue; } ul { padding-left: 100px; list-style-type: circle; } li { color: #123456; /* hexadecimal */ }
Preferred option
Old style:
<head> ... <link rel="stylesheet" type="text/css" href="teamx1.css" /> </head>
Inline it:
<h1 style="color: teal;">My heading</h1>
28/09/2012
28/09/2012
29
30
Highest priority
9. Debugging
Firefox add-on: getfirebug.com
Thus inline styles have highest priority (ignoring !important) Different styles can be applied depending on the output device being used, e.g. screen and print versions
http://en.wikipedia.org/wiki/Cascading_Style_Sheets
28/09/2012 Dr Steve Maddock, The University of Sheffield 28/09/2012 Dr Steve Maddock, The University of Sheffield
31
10. Summary
When creating a Web page, separate the structure and the appearance
The structure is given using HTML The appearance is controlled using CSS (Interaction using JavaScript see a later lecture)
+
style 1 (no style)
+
style 2
Next lectures:
HTML5: div; Semantic elements (header, nav, section, article, footer), figure, ; The box model (); Typography CSS: class and id; Contextual selectors; Pseudo-classes; Inheritance and cascading
margin (transparent) border
padding
content
28/09/2012