SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
sit epoint .com http://www.sitepoint.com/a-basic-html5-template/
A Basic HTML5 Template
This article is an excerpt f rom HTML5 & CSS3 f or the Real World, by Alexis Goldstein, Louis
Lazaris & Estelle Weyl. See more details below.
As you learn HTML5 and add new techniques to your toolbox, you’re likely going to want to build
yourself a blueprint, or boilerplate, f rom which you can begin all your HTML5-based projects. In
f act, you’ve probably already done something similar f or your existing XHTML or HTML 4.0 projects.
We encourage this, and you may also consider using one of the many online sources that provide a basic
HTML5 starting point f or you.[3]
In this project, however, we want to build our code f rom scratch and explain each piece as we go along. Of
course, it would be impossible f or even the most f antastical and unwieldy sample site we could dream up to
include every new element or technique, so we’ll also explain some new f eatures that don’t f it into the
project. This way, you’ll be f amiliar with a wide set of options when deciding how to build your HTML5 and
CSS3 websites and web apps, so you’ll be able to use this book as a quick ref erence f or a number of
techniques.
Let’s start simple, with a bare-bones HTML5 page:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<script src="js/scripts.js"></script>
</body>
</html>
Look closely at the above markup. If you’re making the transition to HTML5 f rom XHTML or HTML 4, then
you’ll immediately notice quite a f ew areas in which HTML5 dif f ers.
The Doctype
First, we have the Document Type Declaration, or doctype. This is simply a way to tell the browser—or any
other parsers—what type of document they’re looking at. In the case of HTML f iles, it means the specif ic
version and f lavor of HTML. The doctype should always be the f irst item at the top of all your HTML f iles. In
the past, the doctype declaration was an ugly and hard-to-remember mess. For XHTML 1.0 Strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
And f or HTML4 Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Over the years, code editing sof tware began to provide HTML templates with the doctype already included,
or else they of f ered a way to automatically insert one. And naturally, a quick web search will easily bring up
the code to insert whatever doctype you require.
Although having that long string of text at the top of our documents hasn’t really hurt us (other than f orcing
our sites’ viewers to download a f ew extra bytes), HTML5 has done away with that indecipherable eyesore.
Now all you need is this:
<!doctype html>
Simple, and to the point. You’ll notice that the “5” is conspicuously missing f rom the declaration. Although the
current iteration of web markup is known as “HTML5,” it really is just an evolution of previous HTML
standards—and f uture specif ications will simply be a development of what we have today. Because
browsers have to support all existing content on the Web, there’s no reliance on the doctype to tell them
which f eatures should be supported in a given document.
The html Element
Next up in any HTML document is the html element, which has not changed signif icantly with HTML5. In our
example, we’ve included the lang attribute with a value of en, which specif ies that the document is in English.
In XHTML-based syntax, you’d be required to include an xmlns attribute. In HTML5, this is no longer needed,
and even the lang attribute is unnecessary f or the document to validate or f unction correctly.
So here’s what we have so f ar, including the closing </html> tag:
<!doctype html>
<html lang="en">
</html>
The head Element
The next part of our page is the <head> section. The f irst line inside the head is the one that def ines the
character encoding f or the document. This is another element that’s been simplif ied. Here’s how you used to
do this:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
HTML5 improves on this by reducing the character encoding <meta> tag to the bare minimum:
<meta charset="utf-8">
In nearly all cases, utf-8 is the value you’ll be using in your documents. A f ull explanation of character
encoding is beyond the scope of this chapter, and it probably won’t be that interesting to you, either.
Nonetheless, if you want to delve a little deeper, you can read up on the topic on the W3C’s site.
note:Get In Early
To ensure that all browsers read the character encoding correctly, the entire character encoding declaration
must be included somewhere within the f irst 512 characters of your document. It should also appear bef ore
any content-based elements (like the <title> element that f ollows it in our example site).
There’s much more we could write about this subject, but we want to keep you awake—so we’ll spare you
those details! For now, we’re content to accept this simplif ied declaration and move on to the next part of
our document:
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
In these lines, HTML5 barely dif f ers f rom previous syntaxes. The page title is declared the same as it always
was, and the <meta> tags we’ve included are merely optional examples to indicate where these would be
placed; you could put as many meta elements here as you like.
The key part of this chunk of markup is the stylesheet, which is included using the customary link element. At
f irst glance, you probably didn’t notice anything dif f erent. But customarily, link elements would include a type
attribute with a value of text/css. Interestingly, this was never required in XHTML or HTML 4—even when
using the Strict doctypes. HTML5-based syntax encourages you to drop the type attribute completely, since
all browsers recognize the content type of linked stylesheets without requiring the extra attribute.
Leveling the Playing Field
The next element in our markup requires a bit of background inf ormation bef ore it can be introduced.
HTML5 includes a number of new elements, such as article and section, which we’ll be covering later on.
You might think this would be a major problem f or older browsers, but you’d be wrong. This is because the
majority of browsers don’t actually care what tags you use. If you had an HTML document with a <recipe>
tag (or even a <ziggy> tag) in it, and your CSS attached some styles to that element, nearly every browser
would proceed as if this were totally normal, applying your styling without complaint.
Of course, this hypothetical document would f ail to validate, but it would render correctly in almost all
browsers—the exception being Internet Explorer. Prior to version 9, IE prevented unrecognized elements
f rom receiving styling. These mystery elements were seen by the rendering engine as “unknown elements,”
so you were unable to change the way they looked or behaved. This includes not only our imagined
elements, but also any elements which had yet to be def ined at the time those browser versions were
developed. That means (you guessed it) the new HTML5 elements.
At the time of writing, Internet Explorer 9 has only just been released (and adoption will be slow), so this is a
bit of a problem. We want to start using the shiny new tags, but if we’re unable to attach any CSS rules to
them, our designs will f all apart.
Fortunately, there’s a solution: a very simple piece of JavaScript, originally developed by John Resig, can
magically make the new HTML5 elements visible to older versions of IE.
We’ve included this so-called “HTML5 shiv”[4] in our markup as a <script> tag surrounded by conditional
comments. Conditional comments are a proprietary f eature implemented by Microsof t in Internet Explorer.
They provide you with the ability to target specif ic versions of that browser with scripts or styles.[5] This
conditional comment is telling the browser that the enclosed markup should only appear to users viewing the
page with Internet Explorer prior to version 9:
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
It should be noted that if you’re using a JavaScript library that deals with HTML5 f eatures or the new APIs,
it’s possible that it will already have the HTML5 enabling script present; in this case, you could remove
ref erence to Remy Sharp’s script. One example of this would be Modernizr, a JavaScript library that detects
modern HTML and CSS f eatures—and which we cover in Appendix A, Modernizr. Modernizr includes code that
enables the HTML5 elements in older versions of IE, so Remy’s script would be redundant.
note:What about users on IE 6-8 who have JavaScript disabled?
Of course, there’s still a group of users who won’t benef it f rom Remy’s HTML5 shiv: those who have, f or
one reason or another, disabled JavaScript. As web designers, we’re constantly told that the content of our
sites should be f ully accessible to all users, even those without JavaScript. When between 40% and 75% of
your audience uses Internet Explorer, this can seem like a serious concern.
But it’s not as bad as it seems. A number of studies have shown that the number of users that have
JavaScript disabled is low enough to be of little concern.
In one study conducted on the Yahoo network, published in October 2010, users with JavaScript disabled
amounted to around 1% of total traf f ic worldwide. Another study indicated a similar number across a billion
visitors. In both studies, the US had the highest number of visitors with JavaScript disabled in comparison to
other parts of the world.
There are ways to use HTML5’s new elements without requiring JavaScript f or the elements to appear styled
in nonsupporting browsers. Unf ortunately, those methods are rather impractical and have other drawbacks.
If you’re still concerned about these users, it might be worth considering a hybrid approach; f or example, use
the new HTML5 elements where the lack of styles won’t be overly problematic, while relying on traditional
elements like divs f or key layout containers.
The Rest is History
Looking at the rest of our starting template, we have the usual body element along with its closing tag and
the closing </html> tag. We also have a ref erence to a JavaScript f ile inside a script element.
Much like the link element discussed earlier, the <script> tag does not require that you declare a type
attribute. In XHTML, to validate a page that contains external scripts, your <script> tag should look like this:
<script src="js/scripts.js" type="text/javascript"></script>
Since JavaScript is, f or all practical purposes, the only real scripting language used on the Web, and since all
browsers will assume that you’re using JavaScript even when you don’t explicitly declare that f act, the type
attribute is unnecessary in HTML5 documents:
<script src="js/scripts.js"></script>
We’ve put the script element at the bottom of our page to conf orm to best practices f or embedding
JavaScript. This has to do with the page loading speed; when a browser encounters a script, it will pause
downloading and rendering the rest of the page while it parses the script. This results in the page appearing
to load much more slowly when large scripts are included at the top of the page bef ore any content. This is
why most scripts should be placed at the very bottom of the page, so that they’ll only be parsed af ter the
rest of the page has loaded.
In some cases (like the HTML5 shiv) the script may need to be placed in the head of your document,
because you want it to take ef f ect bef ore the browser starts rendering the page.
[3] A f ew you might want to look into can be f ound at http://www.html5boilerplate.com/ and
http://html5reset.org/.
[4] You might be more f amiliar with its alternative name: the HTML5 shim. Whilst there are identical code
snippets out there that go by both names, we’ll be ref erring to all instances as the HTML5 shiv, its original
name.
[5] For more inf ormation see http://ref erence.sitepoint.com/css/conditionalcomments
Want more? Check out the book and buy it online at HTML5 & CSS3 f or the Real World, by Alexis Goldstein,
Louis Lazaris & Estelle Weyl. Download the f ree sample chapters, access the book’s code archive, check on
updates and errata or join the conversations on the SitePoint Forums.
And if you enjoyed reading this post, you’ll love Learnable; the place to learn f resh skills and techniques
f rom the masters. Members get instant access to all of SitePoint’s ebooks and interactive online courses,
like HTML5 & CSS3 For the Real World.
Louis Lazaris
More Posts
Related Posts
A Minimal HTML Document (HTML5 Edition)
A Minimal HTML Document
W3C Markup Validation Service adds experimental HTML5 support
5 Reasons Why You Can Use HTML5 Today
Cross-Browser HTML5 Canvas with Fallback

Weitere ähnliche Inhalte

Was ist angesagt?

The Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersThe Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersRasin Bekkevold
 
An SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHPAn SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHPTroyfawkes
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5Sayed Ahmed
 
Vskills certified html designer Notes
Vskills certified html designer NotesVskills certified html designer Notes
Vskills certified html designer NotesVskills
 
Html beginner
Html beginnerHtml beginner
Html beginnerwihrbt
 
HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)actanimation
 
The Future of the Web: HTML5
The Future of the Web: HTML5The Future of the Web: HTML5
The Future of the Web: HTML5Derek Bender
 
Summary of-xhtml-basics
Summary of-xhtml-basicsSummary of-xhtml-basics
Summary of-xhtml-basicsstarlanter
 
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScriptAn Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScriptTroyfawkes
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginnersSingsys Pte Ltd
 
GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1Heather Rock
 
An Introduction to HTML5
An Introduction to HTML5An Introduction to HTML5
An Introduction to HTML5Steven Chipman
 

Was ist angesagt? (17)

The Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersThe Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for Beginners
 
An SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHPAn SEO’s Intro to Web Dev PHP
An SEO’s Intro to Web Dev PHP
 
Basic Html for beginners.
Basic Html for beginners.Basic Html for beginners.
Basic Html for beginners.
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5
 
Html 5 Features And Benefits
Html 5 Features And Benefits  Html 5 Features And Benefits
Html 5 Features And Benefits
 
Vskills certified html designer Notes
Vskills certified html designer NotesVskills certified html designer Notes
Vskills certified html designer Notes
 
Xhtml 2010
Xhtml 2010Xhtml 2010
Xhtml 2010
 
Html beginner
Html beginnerHtml beginner
Html beginner
 
HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)
 
The Future of the Web: HTML5
The Future of the Web: HTML5The Future of the Web: HTML5
The Future of the Web: HTML5
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
Html5 - Tutorial
Html5 - TutorialHtml5 - Tutorial
Html5 - Tutorial
 
Summary of-xhtml-basics
Summary of-xhtml-basicsSummary of-xhtml-basics
Summary of-xhtml-basics
 
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScriptAn Seo’s Intro to Web Dev, HTML, CSS and JavaScript
An Seo’s Intro to Web Dev, HTML, CSS and JavaScript
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
 
GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1GDI Seattle Intro to HTML and CSS - Class 1
GDI Seattle Intro to HTML and CSS - Class 1
 
An Introduction to HTML5
An Introduction to HTML5An Introduction to HTML5
An Introduction to HTML5
 

Andere mochten auch

February 2012 newsletter
February 2012 newsletterFebruary 2012 newsletter
February 2012 newsletterDaniel Downs
 
Ad age advertising century top 100 advertising campaigns
Ad age advertising century  top 100 advertising campaignsAd age advertising century  top 100 advertising campaigns
Ad age advertising century top 100 advertising campaignsDaniel Downs
 

Andere mochten auch (6)

February 2012 newsletter
February 2012 newsletterFebruary 2012 newsletter
February 2012 newsletter
 
Ad age advertising century top 100 advertising campaigns
Ad age advertising century  top 100 advertising campaignsAd age advertising century  top 100 advertising campaigns
Ad age advertising century top 100 advertising campaigns
 
History of pbl
History of pblHistory of pbl
History of pbl
 
Html5 Basics
Html5 BasicsHtml5 Basics
Html5 Basics
 
Html5 CSS3 jQuery Basic
Html5 CSS3 jQuery BasicHtml5 CSS3 jQuery Basic
Html5 CSS3 jQuery Basic
 
HTML5 Basic
HTML5 BasicHTML5 Basic
HTML5 Basic
 

Ähnlich wie Sitepoint.com a basic-html5_template

Ähnlich wie Sitepoint.com a basic-html5_template (20)

Is it time to start using HTML 5
Is it time to start using HTML 5Is it time to start using HTML 5
Is it time to start using HTML 5
 
Html5 tutorial
Html5 tutorialHtml5 tutorial
Html5 tutorial
 
Html5 tutorial
Html5 tutorialHtml5 tutorial
Html5 tutorial
 
Html5 tutorial
Html5 tutorialHtml5 tutorial
Html5 tutorial
 
Html5 tutorial
Html5 tutorialHtml5 tutorial
Html5 tutorial
 
Html5 tutorial
Html5 tutorialHtml5 tutorial
Html5 tutorial
 
Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1
 
WT Module-1.pdf
WT Module-1.pdfWT Module-1.pdf
WT Module-1.pdf
 
Introduction to html5
Introduction to html5Introduction to html5
Introduction to html5
 
What is html xml and xhtml
What is html xml and xhtmlWhat is html xml and xhtml
What is html xml and xhtml
 
Introduction to html55
Introduction to html55Introduction to html55
Introduction to html55
 
Wa html5-pdf
Wa html5-pdfWa html5-pdf
Wa html5-pdf
 
Wa html5-pdf
Wa html5-pdfWa html5-pdf
Wa html5-pdf
 
Wa html5-pdf
Wa html5-pdfWa html5-pdf
Wa html5-pdf
 
Wa html5-pdf
Wa html5-pdfWa html5-pdf
Wa html5-pdf
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
1. Introduction to HTML5.ppt
1. Introduction to HTML5.ppt1. Introduction to HTML5.ppt
1. Introduction to HTML5.ppt
 
1._Introduction_to_HTML5[1].MCA MODULE 1 NOTES
1._Introduction_to_HTML5[1].MCA MODULE 1 NOTES1._Introduction_to_HTML5[1].MCA MODULE 1 NOTES
1._Introduction_to_HTML5[1].MCA MODULE 1 NOTES
 
Html5
Html5Html5
Html5
 
Html5
Html5Html5
Html5
 

Mehr von Daniel Downs

Developing a mobile application curriculum which empowers authentic
Developing a mobile application curriculum which empowers authenticDeveloping a mobile application curriculum which empowers authentic
Developing a mobile application curriculum which empowers authenticDaniel Downs
 
Module11: Creating A External Style Sheet and Creating A Gallery
Module11: Creating A External Style Sheet and Creating A GalleryModule11: Creating A External Style Sheet and Creating A Gallery
Module11: Creating A External Style Sheet and Creating A GalleryDaniel Downs
 
Seo continued page 2
Seo continued page 2Seo continued page 2
Seo continued page 2Daniel Downs
 
Module 10search engine optimization
Module 10search engine optimizationModule 10search engine optimization
Module 10search engine optimizationDaniel Downs
 
Ipad quick-reference-2
Ipad quick-reference-2Ipad quick-reference-2
Ipad quick-reference-2Daniel Downs
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Daniel Downs
 
Jquery template 1 3 pages
Jquery template 1 3 pagesJquery template 1 3 pages
Jquery template 1 3 pagesDaniel Downs
 
Module6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsitesModule6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsitesDaniel Downs
 
Module 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsModule 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsDaniel Downs
 
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington MaModule 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington MaDaniel Downs
 
Module 2 lexington minuteman web development basic layout template
Module 2  lexington minuteman web development basic layout templateModule 2  lexington minuteman web development basic layout template
Module 2 lexington minuteman web development basic layout templateDaniel Downs
 
Module 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington MinutemanModule 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington MinutemanDaniel Downs
 
App research project
App research projectApp research project
App research projectDaniel Downs
 
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...Daniel Downs
 
Blogger custom domain on go daddy blogger widgets
Blogger custom domain on go daddy   blogger widgetsBlogger custom domain on go daddy   blogger widgets
Blogger custom domain on go daddy blogger widgetsDaniel Downs
 
Outline for action research prospectus
Outline for action research prospectusOutline for action research prospectus
Outline for action research prospectusDaniel Downs
 
You have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesignerYou have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesignerDaniel Downs
 
Making a basicappinflash (1)
Making a basicappinflash (1)Making a basicappinflash (1)
Making a basicappinflash (1)Daniel Downs
 
Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)Daniel Downs
 
Web design 1& 2 lesson outline
Web design 1& 2 lesson outlineWeb design 1& 2 lesson outline
Web design 1& 2 lesson outlineDaniel Downs
 

Mehr von Daniel Downs (20)

Developing a mobile application curriculum which empowers authentic
Developing a mobile application curriculum which empowers authenticDeveloping a mobile application curriculum which empowers authentic
Developing a mobile application curriculum which empowers authentic
 
Module11: Creating A External Style Sheet and Creating A Gallery
Module11: Creating A External Style Sheet and Creating A GalleryModule11: Creating A External Style Sheet and Creating A Gallery
Module11: Creating A External Style Sheet and Creating A Gallery
 
Seo continued page 2
Seo continued page 2Seo continued page 2
Seo continued page 2
 
Module 10search engine optimization
Module 10search engine optimizationModule 10search engine optimization
Module 10search engine optimization
 
Ipad quick-reference-2
Ipad quick-reference-2Ipad quick-reference-2
Ipad quick-reference-2
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.
 
Jquery template 1 3 pages
Jquery template 1 3 pagesJquery template 1 3 pages
Jquery template 1 3 pages
 
Module6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsitesModule6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsites
 
Module 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsModule 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel Downs
 
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington MaModule 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
 
Module 2 lexington minuteman web development basic layout template
Module 2  lexington minuteman web development basic layout templateModule 2  lexington minuteman web development basic layout template
Module 2 lexington minuteman web development basic layout template
 
Module 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington MinutemanModule 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington Minuteman
 
App research project
App research projectApp research project
App research project
 
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
 
Blogger custom domain on go daddy blogger widgets
Blogger custom domain on go daddy   blogger widgetsBlogger custom domain on go daddy   blogger widgets
Blogger custom domain on go daddy blogger widgets
 
Outline for action research prospectus
Outline for action research prospectusOutline for action research prospectus
Outline for action research prospectus
 
You have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesignerYou have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesigner
 
Making a basicappinflash (1)
Making a basicappinflash (1)Making a basicappinflash (1)
Making a basicappinflash (1)
 
Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)
 
Web design 1& 2 lesson outline
Web design 1& 2 lesson outlineWeb design 1& 2 lesson outline
Web design 1& 2 lesson outline
 

Kürzlich hochgeladen

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Kürzlich hochgeladen (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Sitepoint.com a basic-html5_template

  • 1. sit epoint .com http://www.sitepoint.com/a-basic-html5-template/ A Basic HTML5 Template This article is an excerpt f rom HTML5 & CSS3 f or the Real World, by Alexis Goldstein, Louis Lazaris & Estelle Weyl. See more details below. As you learn HTML5 and add new techniques to your toolbox, you’re likely going to want to build yourself a blueprint, or boilerplate, f rom which you can begin all your HTML5-based projects. In f act, you’ve probably already done something similar f or your existing XHTML or HTML 4.0 projects. We encourage this, and you may also consider using one of the many online sources that provide a basic HTML5 starting point f or you.[3] In this project, however, we want to build our code f rom scratch and explain each piece as we go along. Of course, it would be impossible f or even the most f antastical and unwieldy sample site we could dream up to include every new element or technique, so we’ll also explain some new f eatures that don’t f it into the project. This way, you’ll be f amiliar with a wide set of options when deciding how to build your HTML5 and CSS3 websites and web apps, so you’ll be able to use this book as a quick ref erence f or a number of techniques. Let’s start simple, with a bare-bones HTML5 page: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>The HTML5 Herald</title> <meta name="description" content="The HTML5 Herald"> <meta name="author" content="SitePoint"> <link rel="stylesheet" href="css/styles.css?v=1.0"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <script src="js/scripts.js"></script> </body> </html> Look closely at the above markup. If you’re making the transition to HTML5 f rom XHTML or HTML 4, then you’ll immediately notice quite a f ew areas in which HTML5 dif f ers. The Doctype First, we have the Document Type Declaration, or doctype. This is simply a way to tell the browser—or any
  • 2. other parsers—what type of document they’re looking at. In the case of HTML f iles, it means the specif ic version and f lavor of HTML. The doctype should always be the f irst item at the top of all your HTML f iles. In the past, the doctype declaration was an ugly and hard-to-remember mess. For XHTML 1.0 Strict: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> And f or HTML4 Transitional: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> Over the years, code editing sof tware began to provide HTML templates with the doctype already included, or else they of f ered a way to automatically insert one. And naturally, a quick web search will easily bring up the code to insert whatever doctype you require. Although having that long string of text at the top of our documents hasn’t really hurt us (other than f orcing our sites’ viewers to download a f ew extra bytes), HTML5 has done away with that indecipherable eyesore. Now all you need is this: <!doctype html> Simple, and to the point. You’ll notice that the “5” is conspicuously missing f rom the declaration. Although the current iteration of web markup is known as “HTML5,” it really is just an evolution of previous HTML standards—and f uture specif ications will simply be a development of what we have today. Because browsers have to support all existing content on the Web, there’s no reliance on the doctype to tell them which f eatures should be supported in a given document. The html Element Next up in any HTML document is the html element, which has not changed signif icantly with HTML5. In our example, we’ve included the lang attribute with a value of en, which specif ies that the document is in English. In XHTML-based syntax, you’d be required to include an xmlns attribute. In HTML5, this is no longer needed, and even the lang attribute is unnecessary f or the document to validate or f unction correctly. So here’s what we have so f ar, including the closing </html> tag: <!doctype html> <html lang="en"> </html> The head Element The next part of our page is the <head> section. The f irst line inside the head is the one that def ines the character encoding f or the document. This is another element that’s been simplif ied. Here’s how you used to do this: <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  • 3. HTML5 improves on this by reducing the character encoding <meta> tag to the bare minimum: <meta charset="utf-8"> In nearly all cases, utf-8 is the value you’ll be using in your documents. A f ull explanation of character encoding is beyond the scope of this chapter, and it probably won’t be that interesting to you, either. Nonetheless, if you want to delve a little deeper, you can read up on the topic on the W3C’s site. note:Get In Early To ensure that all browsers read the character encoding correctly, the entire character encoding declaration must be included somewhere within the f irst 512 characters of your document. It should also appear bef ore any content-based elements (like the <title> element that f ollows it in our example site). There’s much more we could write about this subject, but we want to keep you awake—so we’ll spare you those details! For now, we’re content to accept this simplif ied declaration and move on to the next part of our document: <title>The HTML5 Herald</title> <meta name="description" content="The HTML5 Herald"> <meta name="author" content="SitePoint"> <link rel="stylesheet" href="css/styles.css?v=1.0"> In these lines, HTML5 barely dif f ers f rom previous syntaxes. The page title is declared the same as it always was, and the <meta> tags we’ve included are merely optional examples to indicate where these would be placed; you could put as many meta elements here as you like. The key part of this chunk of markup is the stylesheet, which is included using the customary link element. At f irst glance, you probably didn’t notice anything dif f erent. But customarily, link elements would include a type attribute with a value of text/css. Interestingly, this was never required in XHTML or HTML 4—even when using the Strict doctypes. HTML5-based syntax encourages you to drop the type attribute completely, since all browsers recognize the content type of linked stylesheets without requiring the extra attribute. Leveling the Playing Field The next element in our markup requires a bit of background inf ormation bef ore it can be introduced. HTML5 includes a number of new elements, such as article and section, which we’ll be covering later on. You might think this would be a major problem f or older browsers, but you’d be wrong. This is because the majority of browsers don’t actually care what tags you use. If you had an HTML document with a <recipe> tag (or even a <ziggy> tag) in it, and your CSS attached some styles to that element, nearly every browser would proceed as if this were totally normal, applying your styling without complaint. Of course, this hypothetical document would f ail to validate, but it would render correctly in almost all browsers—the exception being Internet Explorer. Prior to version 9, IE prevented unrecognized elements f rom receiving styling. These mystery elements were seen by the rendering engine as “unknown elements,” so you were unable to change the way they looked or behaved. This includes not only our imagined elements, but also any elements which had yet to be def ined at the time those browser versions were developed. That means (you guessed it) the new HTML5 elements. At the time of writing, Internet Explorer 9 has only just been released (and adoption will be slow), so this is a bit of a problem. We want to start using the shiny new tags, but if we’re unable to attach any CSS rules to them, our designs will f all apart.
  • 4. Fortunately, there’s a solution: a very simple piece of JavaScript, originally developed by John Resig, can magically make the new HTML5 elements visible to older versions of IE. We’ve included this so-called “HTML5 shiv”[4] in our markup as a <script> tag surrounded by conditional comments. Conditional comments are a proprietary f eature implemented by Microsof t in Internet Explorer. They provide you with the ability to target specif ic versions of that browser with scripts or styles.[5] This conditional comment is telling the browser that the enclosed markup should only appear to users viewing the page with Internet Explorer prior to version 9: <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> It should be noted that if you’re using a JavaScript library that deals with HTML5 f eatures or the new APIs, it’s possible that it will already have the HTML5 enabling script present; in this case, you could remove ref erence to Remy Sharp’s script. One example of this would be Modernizr, a JavaScript library that detects modern HTML and CSS f eatures—and which we cover in Appendix A, Modernizr. Modernizr includes code that enables the HTML5 elements in older versions of IE, so Remy’s script would be redundant. note:What about users on IE 6-8 who have JavaScript disabled? Of course, there’s still a group of users who won’t benef it f rom Remy’s HTML5 shiv: those who have, f or one reason or another, disabled JavaScript. As web designers, we’re constantly told that the content of our sites should be f ully accessible to all users, even those without JavaScript. When between 40% and 75% of your audience uses Internet Explorer, this can seem like a serious concern. But it’s not as bad as it seems. A number of studies have shown that the number of users that have JavaScript disabled is low enough to be of little concern. In one study conducted on the Yahoo network, published in October 2010, users with JavaScript disabled amounted to around 1% of total traf f ic worldwide. Another study indicated a similar number across a billion visitors. In both studies, the US had the highest number of visitors with JavaScript disabled in comparison to other parts of the world. There are ways to use HTML5’s new elements without requiring JavaScript f or the elements to appear styled in nonsupporting browsers. Unf ortunately, those methods are rather impractical and have other drawbacks. If you’re still concerned about these users, it might be worth considering a hybrid approach; f or example, use the new HTML5 elements where the lack of styles won’t be overly problematic, while relying on traditional elements like divs f or key layout containers. The Rest is History Looking at the rest of our starting template, we have the usual body element along with its closing tag and the closing </html> tag. We also have a ref erence to a JavaScript f ile inside a script element. Much like the link element discussed earlier, the <script> tag does not require that you declare a type attribute. In XHTML, to validate a page that contains external scripts, your <script> tag should look like this: <script src="js/scripts.js" type="text/javascript"></script> Since JavaScript is, f or all practical purposes, the only real scripting language used on the Web, and since all
  • 5. browsers will assume that you’re using JavaScript even when you don’t explicitly declare that f act, the type attribute is unnecessary in HTML5 documents: <script src="js/scripts.js"></script> We’ve put the script element at the bottom of our page to conf orm to best practices f or embedding JavaScript. This has to do with the page loading speed; when a browser encounters a script, it will pause downloading and rendering the rest of the page while it parses the script. This results in the page appearing to load much more slowly when large scripts are included at the top of the page bef ore any content. This is why most scripts should be placed at the very bottom of the page, so that they’ll only be parsed af ter the rest of the page has loaded. In some cases (like the HTML5 shiv) the script may need to be placed in the head of your document, because you want it to take ef f ect bef ore the browser starts rendering the page. [3] A f ew you might want to look into can be f ound at http://www.html5boilerplate.com/ and http://html5reset.org/. [4] You might be more f amiliar with its alternative name: the HTML5 shim. Whilst there are identical code snippets out there that go by both names, we’ll be ref erring to all instances as the HTML5 shiv, its original name. [5] For more inf ormation see http://ref erence.sitepoint.com/css/conditionalcomments Want more? Check out the book and buy it online at HTML5 & CSS3 f or the Real World, by Alexis Goldstein, Louis Lazaris & Estelle Weyl. Download the f ree sample chapters, access the book’s code archive, check on updates and errata or join the conversations on the SitePoint Forums. And if you enjoyed reading this post, you’ll love Learnable; the place to learn f resh skills and techniques f rom the masters. Members get instant access to all of SitePoint’s ebooks and interactive online courses, like HTML5 & CSS3 For the Real World. Louis Lazaris More Posts Related Posts A Minimal HTML Document (HTML5 Edition) A Minimal HTML Document W3C Markup Validation Service adds experimental HTML5 support 5 Reasons Why You Can Use HTML5 Today Cross-Browser HTML5 Canvas with Fallback