html – introduction to the code. web page a plain text document (no specific software needed) html...

49
HTML – Introduction to the Code

Upload: erik-lester

Post on 25-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML – Introduction to the Code

Page 2: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

WEB PAGEA plain text document (no specific software needed)

HTML Tags - describes a documents structure Saved with .htm or .html extensionHosted on a server

Page 3: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML: Hypertext Markup Language

Simple, universal mark-up language used to publish content on the webStandard mark-up language for web pages

Uses tags to identify content : <p> I am a paragraph </p>

HTML: basic structure

Enhanced & Modified by other technologies CSS: presentation, formatting, layout JavaScript: control behavior of page elements PHP: powerful applications/functionality (backend) CMS: manage site content

Page 4: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML Elements (container tags – markup + content)Empty Tags (standalone)

Page 5: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLHTML Markup Element

HTML Tags placed in angle brackets <>

Consist of two tags: Opening tag | Closing tag (“on” & “off”)

End tag begins with a slash ( / )

Page 6: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML

Empty Tag (Standalone)

Do not have text content

Places an element on the page (provides a directive)

Indicated by single tag

XHTML note: all standalone tags require closing tag (ex: <br> now <br />)

Page 7: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLAttributes: Information or instructions that modify a tag

Attributes use values

Located in the opening tag

One tag can have multiple attributes

Page 8: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm
Page 9: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLBasic HTML Structure

1) <!DOCTYPE html>identifies the document as an HTML document

2) <html>…</html> (root element)First and last tag in a document

3) <head>…</head>Includes descriptive info about your document | Non visual elements (metatags, links to external resources, scripts or internal resources)

4) <meta charset= “utf-8”>character encoding

5) <title>…</title>

Name of page (bookmarks, browser indexing)

6) <body>…</body>Contains visual & structural elements (visible on page)

Page 10: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML4.01|XHTML1.1|HTML5|HTML??the many flavors of HTML….

Page 11: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML VersionsMany versions of HTML

Tim Berners-Lee

Simple, text-only browsing & authoring system to share and manage information

using the hypertext process to link to related documents

Handful of tags

Web content grew (Browsers made a mess of things)

Browser developers implemented new features and new tags into their browsers

HTML continued to grow – new, cool, exciting tags (<background>, <font>, <bgsound>,

<blink>, <image>)

Each browser created its own proprietary tags – only supported by that particular platform

W3C stepped in to help (http://www.w3.org/)

Oversees ongoing development of the web

Keeps track of browser features

Help develop guidelines for common HTML language (HTML 3.2 - 1996) (versions:

http://www.utoronto.ca/webdocs/HTMLdocs/HTML_Spec/html.html)

Page 12: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML VersionsHTML tags - informal CERN document listing 12 tags (1991)HTML 2.0 - specification released in 1995

HTML 3.2 - first version developed and standardized exclusively by the W3C (1996)

HTML 4.0 - published as W3C recommendation (1997)HTML 4.01 - published as W3C recommendation (1999)

XHTML 1.0 - published as W3C recommendation (2000) More structure less presentation (XML based approach)

XHTML 1.1 - published as W3C recommendation (2001)

XHTML 2.0 - NO STANDARD (2002-2009) worked on but abandoned – not backward compliant (new language)

HTML 5 – WHATWG (Web Hypertext Application Tech Working Group) (2004) W3C adopts the work of this group under name HTML 5.0 (2006) Working Draft (2007)

Page 13: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML vs. XHTMLXML - Extensible Markup Language

A metalanguage for creating markup languages•custom markup language to describe all sorts of information (chemical notation, mathematical equations, multimedia presentations, financial information)

W3C VisionXML-based Web with many specialized markup languages working together.

Enter XHTML - Extensible Hypertext Markup Language

HTML rewritten according to the rules of XML (so that it would be compatible with other xml markup)

Page 14: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML vs. XHTMLXHTML - Extensible Hypertext Markup Language

Markup language almost identical to HTML – written with different rules

Allows for the markup of text, inclusion of images, and is capable of linking documents together

XHTML 1.0/1.1XHTML is HTML 4.01 Reformatted using the syntax of XMLHTML 4.01 – Emphasized the separation of presentation from content

structure (presentation handled by CSS)

XHTML follows the more structured and rigid XML rules and syntax guidelines

enables one document to be viewed on multiple devices (web browsers, cell phones, PDAs, etc) by creating different style sheets for each device.HTML V5 and XHTL V2 Explained: http://www.ibm.com/developerworks/library/x-html5xhtml2.html

Page 15: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML vs. XHTMLSyntax DifferencesAll elements must be terminated (close tag)

(Ex: <p> This is XHTML code! </p>)

Empty tags must be terminated (close tag)written with a space and / symbol at the end (ex: <br />)

All elements and attributes must be in lowercase

All attribute values must be contained within quotes

All elements must be nested properly

Page 16: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

XHTML what does it look like?1. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML

1.0 Transitional//EN” http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

”>

2. <html xmlns=“http://www.w3.org/1999/xhtml”>

3. <head>

4. <title>Untitled Document</title>

5. </head>

6. <body>

This is where the content of your page will be placed.

7. </body>

8. </html>

Page 17: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

XHTML what does it look like?1. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML

1.0 Transitional//EN”

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

DOCUMENT TYPE DECLARATION (DOCTYPE):

Defines all elements and attributes in the language & their rules (Identifies which version of html the document follows)

Points to a file that outlines the available structure, elements, attributes, and their appropriate usage (URL to a Doc Type Definition (DTD) – machine readable file)

Page 18: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

DOCUMENT TYPE DEFINITION1. Transitional: maintains backward

compatibility with older browsers includes legacy elements – obsolete (deprecated) elements (includes presentation elements that were in common use)

2. Strict: doesn’t allow any HTML elements that were designed to control the appearance of a page. (omits all deprecated elements)

3. Frameset: allows HTML elements needed to create framesets.

Great explanation can be found at: Child, D. (2004) DTDs Explained, Added Bytes Available: http://www.addedbytes.com/html/dtds-explained/

Niederst, J. (2012) Learning Web Design. O’Reilly Media, Inc. Chapter 10: What's Up, HTML5

ValidatorsChecks the markup to see if its following the rules specified in the DOCTYPE declaration.

Page 19: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

XHTML what does it look like?

2. <html xmlns= http://www.w3.org/1999/xhtml lang=“en” xml:lang=“en”>

XML namespace=

This URL points to a file that gives detailed information about the particular XML vocabulary used on the page.

Page 20: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

XHTML what does it look like?

3. <head> contains all the header information

4. <title> defines the page title </title>

5. </head> closing head tag

6. <body> where all visible content will be placed

7. </body> closing body tag

8. </html> closing html tag

Page 21: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML VersionsHTML tags - informal CERN document listing 12 tags (1991)

HTML 2.0 - specification released in 1995

HTML 3.2 - first version developed and standardized exclusively by the W3C (1996)

HTML 4.0 - published as W3C recommendation (1997)HTML 4.01 - published as W3C recommendation (1999)

XHTML 1.0 - published as W3C recommendation (2000) More structure less presentation (XML based approach)

XHTML 1.1 - published as W3C recommendation (2001)

XHTML 2.0 - NO STANDARD (2002-2009) worked on but abandoned – not backward compliant (new language)

HTML 5 – WHATWG (Web Hypertext Application Tech Working Group) (2004)

W3C adopts the work of this group under name HTML 5.0 (2006) Working Draft (2007)

Page 22: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML 5 Timeline2003 – HTML 5 development begins

2007 Oct - First W3C Working Draft

2009 Oct – Last Call Working Draft

2011 – Call for contributions for the test suite

2012 – First draft of test suite

2015 – Second draft of test suite

2019 – Final version of test suite

2020 – Reissued last call working draft

2022 – Proposed Recommendation

Ian Hickson, editor of HTML 5 Specification (Tech Republic Interview 2008)

Can you use it now? – Yes, some parts of HTML 5User agents (devices & browsers) provide some support now

Entire specification not yet ready for adoption – but some parts are ready to use now

Support Resources : http://findmebyip.com | http://samples.msdn.microsoft.com/ietestcenter/ | http://canisue.com |http://html5test.com

Page 23: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML 5 vs HTML 4

Differences No Doctype needed <!DOCTYPE HTML>

Character Encoding: <meta charset=“UTF-8” />

New Elements: article, aside, audio, canvas, command, datalist, details, embed, figcaption, figure, footer,

header, hgroup, keygen, mark, meter, nav, output, progress, rp, ruby, section, source, summary, time, video

Forms: more powerful form elements(built in validation)

Integrated APIs (Application Programming Interfaces): Easier to develop web applications across multiple

devices.(API = a documented set of commands, data names – lets one

software app communicate with another)

Page 24: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

1. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML

1.0 Transitional//EN” http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

2. <html xmlns=“http://www.w3.org/1999/xhtml”>

3. <head>

4. <title>Title of Document</title>

5. </head>

6. <body>

This is where the content of your page will be placed.

7. </body>

8. </html>

Back to the Code

Page 25: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTML Common Elements

Block & Inline Elements

Block Elements Ex: <p /> <h1>…</h1>Each block element begins a new lineHave space above and below the element by default

<h1> This is the most important heading </h1>

<p> This is a paragraph </p>

Inline Elements Ex: <em>…</em>Flow within other elements (do not start new line)

<p> This is a paragraph with <em> emphasized text </em> within (inline) the paragraph element </p>

Page 26: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLBlock Level Elements

Paragraphs <p>…</p>

Headings <h#>…</h#> (six levels of headings)provides logical hierarchyimproves accessibility

Block quote <blockquote>…</blockquote>

Preformatted text <pre>…</pre>preserves white spaces – returns and character spacesMay be needed to convey meaning (code, poetry)

Horizontal Rules <hr />

Page 27: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLBlock Level Elements

Unordered Lists <ul>…</ul> & <li>…</li>Default is disc change type: <ul type=“circle”>, “square”

Ordered Lists <ol>…</ol> & <li>…</li>Default is #’s change type: <ol type=“A”> “a”, “I”, “i”

Definition Lists <dl>…</dl> & <dt>…</dt> & <dd>…</dd>

Note: Changing type and start value not supported in “strict” versions of XHTML

http://www.w3schools.com/html/html_lists.asp

Page 28: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLInline Elements

Line Breaks <br />

Semantic inline text elements

Describes the meaning of the text

Examples: <em>for emphasis, <strong> strongly emphasized, <q> short inline quote

Presentational inline text elements

provides descriptions of the elements styleExamples: <b> keywords or visually emphasized text (bold) Ex: product name, <i> Alternative voice (italics) Ex: phrase, technical term, thought(please use: <strong> & <em> instead)

Page 29: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLSpecial Characters

Must use numeric or named character reference

Examples

Character space (&nbsp;)

& Ampersand (&amp;)

© Copyright symbol (&copy;)

Euro (&euro;)

Page 30: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Meaningful MarkupSemantic Markup

•Semantic Markup uses tags or elements that describe the content by its function. •Adds meaning for the machine

Browsers, mobile devices, screen readers, search engines can not “see” the page… they extract meaning and context from the markup.

Page 31: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

<h1>This is the most important headline</h1><p>This is ordinary paragraph text within the body of the document, where certainwords and phrases may be <em>emphasized</em> to mark them as<strong>particularly important</strong>.</p><h2>This is a headline of secondary importance to the headline above</h2><p>Any time you list related things, the items should be marked up in the form of a list:</p><ul><li>A list signals that a group of items are conceptually related to each other</li><li>Lists may be ordered (numbered or alphabetic) or unordered (bulleted items)</li><li>Lists may also be menus or lists of links for navigation </li><li>Cascading Style Sheets can make lists look many different ways</li></ul>

Meaningful Markup – No Presentation Info

Browsers, mobile devices, screen readers, search engines can not “see” the page… they extract meaning and context from the markup.

The Site Development Processhttp://webstyleguide.com

Page 32: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLImages

img tag <img>

Required attribute: src

<img src=“uwm_logo.gif” alt=“UWM Logo” />

http://www.w3schools.com/html/html_images.asp

Page 33: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HYPERTEXT – it’s a web… things are linked…

Page 34: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

HTMLLinks

The anchor <a>…</a>

Required attribute: href

<a href=http://www.uwm.edu> Link to UWM </a><a href=http://www.uwm.edu><img src=“uwm_logo.gif”/>UWM</a>

Page 35: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Site Directory and File Structure

•Often mirrors visible site structure•Logical naming conventions – plain language•Creates useful/understandable URLs

6,100 Files250 Folders

Page 36: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Hypertext – Absolute & Relative LinksAbsolute Links

<a href=“http://www.uwm.edu”> UW-Milwaukee </a>also called an external link

Relative Links

<a href=“admissions.html”> Link to admissions page </a>

Relative links do not require the protocol and domain name

These links are “related” to the current page (The page you want to link to is within the same domain as the document you are linking from)

Page 37: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

If you were working on your about.html document and you wanted to create a link to your index.html document, your link would look like this:

<a href=“index.html”> HOME </a>

Page 38: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

If you were working on your index.html document and you wanted to create a link to your advising.html document, your link would look like this:

<a href=“academics/advising.html”> Advising</a>

Page 39: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

If you were working on your root level (main) index.html document and you wanted to create a link to your comps.html document, you link would look like this:

<a href=“academics/graduate/comps.html”> Comps </a>

Page 40: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Index??Significance of “index”

Usually the default filename a browser will look for if no filename is provide.

http://www.sois.uwm.edu/EPub/Spring_2012

retrieving a file called “index.html” in the Spring_2012 folder

Page 41: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

If you were working on your mlis.html document and you wanted to create a link to your advising.html document, your link would look like this:

<a href=“../advising.html”> Advising</a>

Page 42: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

<a href=“../../index.html”>Back to Home</a>

Page 43: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

CSS – Presentation of Information

Page 44: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

<h1>This is the most important headline</h1><p>This is ordinary paragraph text within the body of the document, where certainwords and phrases may be <em>emphasized</em> to mark them as<strong>particularly important</strong>.</p><h2>This is a headline of secondary importance to the headline above</h2><p>Any time you list related things, the items should be marked up in the form of a list:</p><ul><li>A list signals that a group of items are conceptually related to each other</li><li>Lists may be ordered (numbered or alphabetic) or unordered (bulleted items)</li><li>Lists may also be menus or lists of links for navigation </li><li>Cascading Style Sheets can make lists look many different ways</li></ul>

Meaningful Markup – No Presentation Info

Browsers, mobile devices, screen readers, search engines can not “see” the page… they extract meaning and context from the markup.

The Site Development Processhttp://webstyleguide.com

Page 45: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Presentation handled by CSS

CSS – Cascading Style Sheets A style-sheet language developed to control the presentation of HTML documents

Allows for the separates the presentation (formatting) from the structure and content of the page.

Structure = the content (headings, lists, paragraphs) Presentation = how the structure looks visually in the user agent (red, bold, verdana)

CSS – used to format the presentation of the contentfonts, colors, layout

Page 46: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Benefits of CSS

Offers more control

•Offers more control•One CSS file can control thousands of pages (more efficient)•More control over formatting

•Precise formatting: Line spacing, type sizes, rollovers, layout

•Modular design - same site content and structure can be style for different output devices

•Media types: Screen(browsers), mobile devices, print, screen reader

•Smaller files / Faster download•No redundant formatting tags

Page 47: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Example of CSS

Separate language with its own syntax

1.Selectors: Selects the element to be affected

2.Declaration: “declares” a style for a selected element

Declaration block: property & value

Page 48: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

Example of CSSDeclaration block

Property: identifies what to change

Value: how to change it

Selector – exampleh1{

font-size: small;

font-family: Georgia, ‘Times New Roman’, Times, serif;

color: #CC3300;

margin-top: 4em;

margin-bottom: 10em;

}

Page 49: HTML – Introduction to the Code. WEB PAGE A plain text document (no specific software needed) HTML Tags - describes a documents structure Saved with.htm

CSS for layout

Exampleshttp://www.shinybytes.com/newcss.html