Академический Документы
Профессиональный Документы
Культура Документы
The new standard incorporates features like video playback and drag-
and-drop that have been previously dependent on third-party browser
plug-ins such as Adobe Flash, Microsoft Silverlight, and Google
Gears.
Browser Support
The latest versions of Apple Safari, Google Chrome, Mozilla Firefox,
and Opera all support many HTML5 features and Internet Explorer 9.0
will also have support for some HTML5 functionality.
New Features
HTML5 introduces a number of new elements and attributes that can
help you in building modern websites. Here is a set of some of the
most prominent features introduced in HTML5.
Forms 2.0 − Improvements to HTML web forms where new attributes have
been introduced for <input> tag.
Audio & Video − You can embed audio or video on your webpages without
resorting to third-party plugins.
Microdata − This lets you create your own vocabularies beyond HTML5 and
extend your web pages with custom semantics.
Drag and drop − Drag and drop the items from one location to another
location on the same webpage.
The element content is everything between the start tag and the end tag
The DOCTYPE
DOCTYPEs in older versions of HTML were longer because the HTML
language was SGML based and therefore required a reference to a DTD.
<!DOCTYPE html>
The above syntax is case-insensitive.
Character Encoding
HTML 5 authors can use simple syntax to specify Character Encoding
as follows −
HTML 5 removes extra information required and you can use simply
following syntax −
HTML 5 removes extra information required and you can use simply
following syntax −
HTML 5 removes extra information required and you can simply use the
following syntax −
HTML5 Elements
HTML5 elements are marked up using start tags and end tags. Tags are
delimited using angle brackets with the tag name in between.
The difference between start tags and end tags is that the latter
includes a slash before the tag name.
<p>...</p>
HTML5 tag names are case insensitive and may be written in all
uppercase or mixed case, although the most common convention is to
stick with lowercase.
HTML5 Attributes
Elements may contain attributes that are used to set various
properties of an element.
Some attributes are defined globally and can be used on any element,
while others are defined for specific elements only. All attributes
have a name and a value and look like as shown below in the example.
Attributes may only be specified within start tags and must never be
used in end tags.
HTML5 Document
The following tags have been introduced for better structure –
figure − This tag can be used to associate a caption together with some
embedded content, such as a graphic or video
The markup for an HTML 5 document would look like the following −
<!DOCTYPE html>
<html>
<head>
<title>...</title>
</head>
<body>
<header>...</header>
<nav>...</nav>
<article>
<section>
...
</section>
</article>
<aside>...</aside>
<footer>...</footer>
</body>
</html>
Basic HTML5 Document.
This HTML5 example starts with a DOCTYPE followed by an html element. The html element has
a lang attribute that specifies the language of the document. Inside the html element there
is a head element followed by a body element. The head element contains information about
the HTML document. The body element contains the main content of the HTML document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
</body>
</html>
Text
P element <p>...</p>
BR Element <br>
The br element represents a line break. It does not have an end tag,
it only has a start tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6>This is a heading</h6>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<h1>Examples</h1>
<h2>First Paragraph</h2>
<h2>Second Paragraph</h2>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<h2>First Paragraph</h2>
<h2>Second Paragraph</h2>
</body>
</html>
The img element represents an image. It does not have an end tag, it
only has a start tag. The source image URL is specified by using
the src attribute.
<body>
<h1>This is an image.</h1>
</body>
A Element <a>
This example encloses an a element inside of a p element. Additional text is added before
and after the a element.
<p>Go to
today.</p>
IMG element added inside of an Anchor element
An img element is added between the start and end a tags. This allows the user to be taken
to the specified URL when the image is clicked.
<body>
<h1>This is an image.</h1>
<p>Click on image
<a href="http://www.littlewebhut.com">
</a>
</p>
</body>
Example:
Audio can be added to a web page by using the audio element. The audio element has a start
and an end tag. In this example, two source URLs are specified by using
two source elements. The text that comes after the second source element will be displayed
in browsers that do not support the audioelement.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<audio controls>
<source src="bell_audio.mp3" type="audio/mpeg">
</audio>
</body>
</html>
Video can be added to a web page by using the video element. The video element has a start
and an end tag. In this example, two source URLs are specified by using
two source elements. The text that comes after the second source element will be displayed
in browsers that do not support the videoelement.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example document</title>
</head>
<body>
<video controls>
</video>
</body>
</html>
New Semantic Elements
New Semantic Elements <article> <aside> <footer> <header>
<main> <nav> <section>
The following is the HTML code for a sample web page that uses semantic elements that are
new to HTML5.
<!DOCTYPE html>
<html>
<head>
<title>...</title>
</head>
<body>
</header>
<nav>
<ul>
<li><a href =
"https://www.tutorialspoint.com/javascript">
JavaScript Tutorial</a></li>
</ul>
</nav>
<article>
<section>
</section>
</article>
<aside>
</aside>
<footer>
</footer>
</body>
</html>
Example2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>News</title>
</head>
<body>
<header>
<h1>News</h1>
</header>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="archive.html">Archives</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>
<main>
<section>
<h2>Local News</h2>
<article>
<header>
<p>(author, date)</p>
</header>
</article>
<article>
<header>
<p>(author, date)</p>
</header>
</article>
</section>
<section>
<h2>National News</h2>
<article>
<header>
<p>(author, date)</p>
</header>
</article>
<article>
<header>
<h3>Thousands are without power</h3>
<p>(author, date)</p>
</header>
</article>
</section>
</main>
<aside>
</aside>
<footer>
<p>Footer Information</p>
</footer>
</body>
</html>