CS7026: Authoring for Digital Media HTML5: Main Structure.

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Ideas to Layout Beginning web layout using Cascading Style Sheets (CSS). Basic ideas, practices, tools and resources for designing a tableless web site.
Quiz #3 - CSS Lecture Code: Get Neighbors’ URLs for MP1
Cascading Style Sheets
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
MMDE5011 – INTERACTIVE MEDIA PRACTICE 1 WEEK 1: INTRODUCTION TO HTML5
New Semantic Elements (Part 2)
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
New Semantic Elements (Part 1). Semantics Explained The textbook definition of "semantics" is the study of the relationship between words and their meanings.
Unit 2, cont. September 14 HTML,Validating your pages, Publishing your site.
Purpose Tags are the key to marking up content on your HTML page. It’s the tags that mark up sections of the page and are defined (aesthetically) on the.
Chapter 14 Introduction to HTML
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Computer Sciences Department
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
Creating Web Pages with HTML
Principles of Web Design 6 th Edition Chapter 1 – HTML5.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
IPUB 100 Lesson 2 Instructor Mark Lamontagne Homework Review.
Online Chapter 1 4 th Edition.  Review elements  Whitespace handling  Rule structure  Linking to an external style sheet  Alternate Style Sheets.
CO1552 – Web Application Development Lists, Special Characters, and Tables.
Week 1.  Phillip Chee   Ext.1214 
Lesson 4: Using HTML5 Markup.  The distinguishing characteristics of HTML5 syntax  The new HTML5 sectioning elements  Adding support for HTML5 elements.
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
HTML (HyperText Markup Language)
Programming in HTML.  Programming Language  Used to design/create web pages  Hyper Text Markup Language  Markup Language  Series of Markup tags 
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Essential HTML coding By Fadi Safieddine (Week 2)
Essential Tags Web Design – Sec 3-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
IDs versus Classes Naming Your Tags for Maximum Functionality.
Copyright © 2013 MyGraphicsLab / Pearson Education STRUCTURE AND HTML TAGS MyGraphicsLab: Adobe Dreamweaver CS6 ACA Certification Preparation for Web Communication.
The New Elements © Main Menu Structure Media Canvas Form Click on one of the categories below to view information about the new HTML5 elements in.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
INTRODUCTION TO HTML5 Semantic Layout in HTML5.  The new semantic layout in HTML5 refers to a new class of elements that is designed to help you understand.
HTML: Hyptertext Markup Language Doman’s Sections.
>> HTML: Structure Elements. Elements in HTML are either Inline or Block. Block-level Elements – Begins on a new line – Occupy the whole width – Stacks.
Tutorial 8 Designing a Web Site with Frames. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore the uses of frames.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
Introduction to HTML UWWD. Agenda What do you need? What do you need? What are HTML, CSS, and tags? What are HTML, CSS, and tags? html, head, and body.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
Objective: To describe the evolution of the Internet and the Web. Explain the need for web standards. Describe universal design. Identify benefits of accessible.
Basic HTML Document Structure. Slide 2 Goals (XHTML HTML5) XHTML Separate document structure and content from document formatting HTML 5 Create a formal.
CHAPTER TWO HTML TAGS. 1.Basic HTML Tags 1.1 HTML: Hypertext Markup Language  HTML stands for Hypertext Markup Language.  It is the markup language.
HTML5 Introduction to Web Programming. Plan of the course HTML5 Structure of a document Main HTML Tags –Headings –Paragraphs –Links –Tables –Forms –Images.
Session: 8. © Aptech Ltd. 2Creating Navigational Aids and Division-Based Layout / Session 8  Explain HTML5 semantic tags  Explain HTML5 semantic tag.
CSS IS A LANGUAGE DESIGNED TO TARGET HTML ELEMENTS AND NODES BY TYPE, CLASS, ID AND VALUE, AND CHANGE THEIR VALUES CSS – change how your HTML looks and.
BEGINNER WEB DESIGN. INTRODUCTION Vocabulary Design Tools of the Trade HTML CSS.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
Web Design Principles 5 th Edition Chapter 3 Writing HTML for the Modern Web.
Cascading Style Sheets for layout
DHTML.
HTML CS 4640 Programming Languages for Web Applications
Web Development & Design Foundations with HTML5 7th Edition
Cascading Style Sheets for layout
Creating a Baseline Grid
Web Development & Design Foundations with HTML5 7th Edition
Basic HTML Document Structure
Styles and the Box Model
Web Development & Design Foundations with HTML5 8th Edition
New Semantic Elements (Part 2)
HTML 5 SEMANTIC ELEMENTS.
New Semantic Elements (Part 1)
HTML5 Tags By Dr Derek Peacock
HTML CS 4640 Programming Languages for Web Applications
Presentation transcript:

CS7026: Authoring for Digital Media HTML5: Main Structure

HTML5  We are going to:  Structure the main sections of a web page using,,,, and,  Style the new elements with CSS.  look at HTML5 Shiv. 2

HTML5 Structural Elements  HTML 4 reflects the early Web of scientists and engineers. Whereas HTML5 reflects the Web as it was during its development.  Hickson did an analysis of class names over 1 billion web pages to find out what the real web was made of  So there are some new semantic structural elements, many of them inspired by these class names, because that’s what developers actually build. 3

HTML5 Structural Elements  4

 Here is a sample home page marked up as we do in XHTML 1.0 using the semantically neutral element: Interesting Articles Menu Last week Archives HTML5 Rocks HTML5 proves easier to write than XHTML1.0 – Shock!... XHTML 2.0 Dies XHTML 2.0 is no longer in development... CS7026: Authoring for Digital Media. 5

Structural Elements  By applying some simple CSS to it, we’ll style it: #sidebar {float:left; width:20%;}.post {float:right; width:79%;} #footer {clear:both;} 6

Structural Elements  Diagrammatically, the page looks like this: 7

Structural Elements  There is nothing at all wrong with this markup (and it’ll continue validating and working perfectly well in the new HTML5 world).  However, most of the structure is entirely unknown to a browser, as the only real HTML element we can use for these important page landmarks is the semantically neutral (defined in HTML 4 as “a generic mechanism for adding structure to documents”). 8

Semantic Elements  It’s possible to imagine a clever browser having a shortcut key that would jump straight to the page’s navigation.  The question is: how would it know what to jump to? Some users use, others use class=”nav” or class=”navigation” or class=”links” and that’s only in English.  HTML5 gives us new elements that unambiguously denote landmarks in a page. 9

Interesting Articles Menu Last week Archives HTML5 Rocks HTML5 proves easier to write than XHTML1.0 - Shock!.... XHTML 2.0 Dies XHTML 2.0 is no longer in development... CS7026: Authoring for Digital Media. 10

Semantic Elements  Diagrammatically, the HTML5 version is this: 11

Styling HTML5 with CSS  Before we look in detail at when to use these new elements, and what they mean, let’s first style the basic structures of the page.  Styling these new elements is pretty simple.  Theoretically you can apply CSS to any arbitrary element, because, as the spec says, CSS “is a style sheet language that allows authors and users to attach style … to structured documents (e.g., HTML documents and XML applications)” and XML applications can have any elements they want. 12

Styling HTML5 with CSS  Although you can use the new HTML5 elements now, most browsers, even current ones, don’t necessarily understand them.  They don’t do anything special with them and treat them like unknown elements you make up.  Therefore, using CSS we can float, put borders on and, and give margins and padding to almost as easily we can with s. 13

Styling HTML5 with CSS  However, by default, CSS assumes that elements are display:inline.  So if you just set heights and widths to the structural elements as we do s, it won’t work properly in the current crop of browsers until we explicitly tell the browser that they are display:block. 14

Styling HTML5 with CSS  So, to style our HTML5 to match our HTML 4 design, we simply need the styles: header, nav, footer, article{display:block;} nav {float:left; width:20%;} article {float:right; width:79%;} footer {clear:both;}  And a beautiful HTML5 page is born. 15

When to Use the New Structural Elements  In our example above, as on most sites, the header will be the first element on a page, and contains the title of the site, logos, links back to the home page, etc.  The specification says: “The header element represents a group of introductory or navigational aids... Note: A header element is intended to usually contain the section’s heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section’s table of contents, a search form, or any relevant logos.” 16

When to Use the New Structural Elements  The first thing to note is that a header element is not required; in our example, it’s superfluous as it surrounds just the.  Its value is that it groups “introductory or navigational” elements, so here’s a more realistic example: Interesting Articles 17

When to Use the New Structural Elements  Many websites have a title and a tagline or subtitle.  To make the main heading and subtitle into one logical unit the they can be grouped in the new element: My Poetry A Collection of my Favourite Poems 18

When to Use the new Structural Elements  The header can also contain navigation: My Poetry A Collection of my Favourite Poems Home Authors Contact 19

When to Use the new Structural Elements  The element is designed to mark up navigation.  Navigation is defined as being links around a page (e.g., a table of contents at the top of an article that links to anchor points on the same page) or within a site.  As with all of the new structural elements, you’re not restricted to one per page.  You might very well have site-wide in a header, a which is a table of contents for the current content, and a below that which links to other related content on your site. 20

When to Use the New Structural Elements  It often makes sense to use a list for your navigation as it both semantically correct and it gives you more hooks for CSS (see  However it’s not mandatory. This is perfectly valid: Home About 21

When to Use the New Structural Elements  You can include headings for navigation, too: Main navigation About me News 22

When to Use the New Structural Elements Grouping and other elements  Many sites have a sidebar that includes multiple blocks of navigation and other non-navigation content.  The elements contained in the new element “can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page.” element. element 23

When to Use the New Structural Elements Pages..... Recent comments... blah blah Web hosting by LovelyHost Powered by WordPress Comments (RSS) 24

When to Use the New Structural Elements  Defined as representing “a footer for its nearest ancestor sectioning content or sectioning root element.” (“Sectioning content” includes article, aside, nav, section, and “sectioning root elements” are blockquote, body, details, fieldset, figure, td).  Again, there can be more than one footer on a page.  The spec continues “A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.” 25

When to Use the New Structural Elements  Our footer holds information which you can wrap in a element, too.  has been redefined in HTML5; previously it was a presentational element, but in HTML5 it represents small print.  “Small print typically features disclaimers, caveats, legal restrictions, or copyrights. Small print is also sometimes used for attribution, or for satisfying licensing requirements.” 26

When to Use the New Structural Elements  The main content of our page contains a few articles. We wrap each one up in an element.  is specified thus: “The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g., in syndication.”  Basically some stand-alone content.  A blog post, a tutorial, a news story, comic strip, or a video with its transcript all fit perfectly into this definition. 27

When to Use the New Structural Elements  Note that, as with, the heading goes inside the element, so... My article Blah blah is incorrect; it should be My article Blah blah 28

HTML Shiv (an important aside…) Shiv (or Shim): an application compatibility workaround

HTML5 Shiv  Every browser has a list of HTML elements that it supports.  Elements not on this list are treated as “unknown elements”.  There a 2 fundamental questions regarding these “unknown elements”  How should the element be styled?  What should the element’s DOM look like? 30

HTML5 Shiv  E.g. Mozilla Firefox’s list of elements is stored in nsElementTable.cpp. nsElementTable.cpp  This includes information about what kinds of other elements each element can contain.  E.g. If you include markup like, the second paragraph element implicitly closes the first one, so the elements end up as siblings, not parent and child.  But if you write, the image does not close the paragraph, because Firefox knows that is a block element that can contain the inline element. So the ends up as a child of the in the DOM. 31

HTML5 Shiv  However, when it comes to “unknown elements” different browsers answer these questions in different ways.  Of the major browsers, Microsoft Internet Explorer’s answer to both questions was the most problematic.  The first question should be relatively simple to answer: don’t give any special styling to unknown elements. Just let them inherit whatever CSS properties are in effect wherever they appear on the page, and let the page author specify all styling with CSS. 32

HTML5 Shiv  Unfortunately, Internet Explorer (prior to Version 9) does not allow styling on unknown elements. For example, if you had this markup: article {display: block; border: 1px solid red }... Welcome to TCD This is your first day. Internet Explorer (up to and including IE 8) will not put a red border around the article. 33

HTML5 Shiv  The second problem is the DOM that browsers create when they encounter unknown elements.  If IE doesn’t explicitly recognize the element name, it will insert the element into the DOM as an empty node with no children.  All the elements that you would expect to be direct children of the unknown element will actually be inserted as siblings instead. 34

HTML5 Shiv  So this is the DOM that HTML5 dictates : article | +--h1 (child of article) | | +--text node "Welcome to TCD" | +--p (child of article, sibling of h1) | +--text node "This is your " | +--span | | +--text node "first day" | +--text node "." 35

HTML5 Shiv  But this is the DOM that Internet Explorer actually creates: article (no children) h1 (sibling of article) | +--text node "Welcome to TCD" p (sibling of h1) | +--text node "This is your " | +--span | | +--text node "first day" | +--text node "." 36

HTML5 Shiv  However, if you create a dummy element with JavaScript before you use it in your page, Internet Explorer will magically recognize the element and let you style it with CSS. 37

HTML5 Shiv document.createElement("article"); Welcome to TCD This is your first day. 38

HTML5 Shiv  This works in all versions of Internet Explorer, all the way back to IE 6.  We can extend this technique to create dummy copies of all the new HTML5 elements and then just start using them without having to worry too much about non- HTML5-capable browsers. 39

HTML5 Shiv  Remy Sharp has done just that, with his aptly named “HTML5 enabling script” or HTML5 shiv  The script has gone through several revisions, but this is the basic idea: var e = ("abbr,article,aside,audio,canvas,datalist,details," + "figure,footer,header,hgroup,mark,menu,meter,nav,output," + "progress,section,time,video").split(','); for (var i = 0; i < e.length; i++) { document.createElement(e[i]); } 40

HTML5 Shiv  The and bits are conditional comments.  Internet Explorer interprets them like an if statement: “if the current browser is a version of Internet Explorer less than Version 9, then execute this block.”  Every other browser will treat the entire block as an HTML comment. The net result is that Internet Explorer (up to and including Version 8) will execute this script, but other browsers will ignore it altogether.  This makes your page load faster in browsers that don’t need this hack. 41

HTML5 Shiv  The JavaScript code itself is relatively straightforward: 1. The variable e ends up as an array of strings like "abbr", "article", "aside", and so on. 2. Then we loop through this array and create each of the named elements by calling document.createElement().  This is enough to get Internet Explorer to treat these elements the way we want them to be treated when we actually use them later in the page. 42

HTML5 Shiv  That “later” bit is important. This script needs to be at the top of your page - preferably in your element - not at the bottom.  That way, Internet Explorer will execute the script before it parses your tags and attributes.  If you put this script at the bottom of your page, it will be too late. Internet Explorer will have already misinterpreted your markup and constructed the wrong DOM, and it won’t go back and adjust it just because of this script. 43

HTML5 Shiv  Remy Sharp has “minified” this script and hosted it on Google Project Hosting.  The script itself is open source and MIT-licensed, so you can use it in any project.  If you like, you can even “hotlink” the script by pointing directly to the hosted version, like this: My HTML5 Page 44