Thursday, 15 March 2012

What is different between HTML5 and HTML4?

HTML5 syntax is almost exactly like HTML4, they are compatible together and all current browsers support HTML5. In below are some of different between HTML5 & HTML4
  • DOCTYPE isn’t required
  • <audio><video> tages
  • graphic include
  • storage location on client side (in HTML4 browser cache used as temporary storage)
  • only modern browser support
  • Not needed in HTML5: type="text/css" ,  type="text/javascript",  <link rel="stylesheet" … />
  • Self-closing tag can now end with just the >,  <br /> can now be <br> again
Instead of div tag you can use different tags like:

<header>, <nav>, <section>, <article>, <aside>, <figure>, <hgroup> and <footer>

<header>: replace div id="header"
<hgroup> : for grouping a series of <h#> tags
<nav> :  links to other pages or parts within the page
<section> : a grouping of content elements inside, section element by itself with more sections within and replace div id="content"
<article>: Standalone content that can be republished, nesting article elements. Example: user comments on a blog entry. Do not over use, it's not a replacement for the div tag
<aside> : for separate from the main content of the page and could be nested inside other article or section elements. Use for quotes, blog , advertising, groups of content.
<figure> : for separate image and image’s content
<footer>: contains info section such as who wrote it, links to related documents, copyright data, etc. Cannot put a header or article tag and replace of <div id="footer">

When to use div? For content being grouped simply for stylistic reasons. We use div, when no other element is suitable.
Use <b> or <i> to bold and italicize content for stylistic reasons. Use <strong> or <em> to stress the meaning of the content.

CSS Reset file? Removes browser inconsistent default styling of HTML elements. Such as height, font sizes, margins, headings, etc. We have to add ‘@import url("reset.css");’ in JavaScript file.

No comments:

Post a Comment