Differences between html4 and html5. HTML5 Preview

The article briefly discusses the differences between html5 and html 4.
Syntax, character encoding, new elements, new attributes, API. We'll also look at retired attributes and a number of significant changes.

HTML 5 is still in development, but a lot of interesting things are already known about it. At first glance, the innovations seem contradictory; time will tell how things will turn out in reality.

Syntax

HTML 5 will have two syntaxes - "custom" HTML and XML. HTML syntax defines detailed parsing rules (including "error handling"). User agents will follow these rules for documents that have a MIME type of text/html. Here is an example of the HTML syntax: The XML syntax is compatible with XHTML1 documents and its implementations. To use this syntax, the MIME type must be declared as an XML type, and the elements must be constructed according to the XML specification. Below is an example that follows XML syntax:

01

03 < head >

04 < title >Example document

05

06 < body >

07 < p >Example paragraph

08

09

Character encoding

For HTML syntax, developers can use three ways to set the encoding: - at the transport level. When using the Content-Type HTTP header, for example. - using the Unicode Byte Order Mark (BOM) character at the beginning of the file. This character provides a signature of the encoding used. - using a meta tag with a charset attribute, which must be defined as the first child element of head. Please note that the encoding is determined using

For XML syntax, developers must follow the rules of the XML specifications.

New elements

  • section represents part of a document or section
  • article represents an independent piece of content for inclusion in an article document
  • aside represents a piece of content that is only partially related to the rest of the page
  • header represents the title section
  • footer- footer, may contain information about the author, copyright and so on
  • nav represents a section of a document intended for navigation
  • dialogue can be used to highlight dialogs:
  • 01 < dialog >
  • 02 < dt >Costello

    03 < dd >Look, you gotta first baseman?

    04 < dt >Abbott

    05 < dd >Certainly.

    06 < dt >Costello

    07 < dd >Who's playing first?

    08 < dt >Abbott

    09 < dd >That's right.

    10 < dt >Costello

    11 < dd >When you pay off the first baseman every month, who gets the money?

    12 < dt >Abbott

    13 < dd >Every dollar of it.

    14

  • figure can be used to link a title to media content:
  • audio And video for multimedia. Both provide the corresponding API. This allows developers to script their own user interface, but also provides a way to call the standard user agent API. Can be used together with these elements source, if it is possible to organize parallel threads.
  • embed used for plugin content.
  • meter- to represent units of measurement.
  • time- date and/or time.
  • canvas used for dynamic graphics rendering.
  • command represents a command that the user can invoke.
  • datagrid- interactive presentation of a tree-type list or tabular data.
  • details represents additional information that the user can obtain upon request.
  • datalist along with a new attribute list used to make a combobox:

    1 < input list = browsers >

    2 < datalist id = browsers >

    3 < option value = "Safari" >

    4 < option value = "Internet Explorer" >

    5 < option value = "Opera" >

    6 < option value = "Firefox" >

    7

  • datatemplate, rule, And nest provide a templating mechanism for HTML.
  • event-source used to intercept events sent by the server.
  • output represents a specific type of output, for example from calculations made through a script.
  • progress represents the progress of a task, such as a download.
  • Attribute type element input now has the following new meanings:
    • datetime
    • datetime-local
    • date
    • month
    • week
    • time
    • number
    • range
    • email
    The idea behind these new types is that the user agent can provide an interface to objects such as a calendar (date picker), address book integration, and provide the server with data in a specific format. This has certain benefits for both users and developers, since user input is validated before being sent to the server by the browser. This means that developers do not need to waste resources on validating entered data, which in turn leads to shorter response times.

New attributes

HTML 5 introduces several new attributes for elements that were already included in HTML 4:
  • elements a And area received a new ping flag, which defines a list of URI addresses that should be pinged when following a hyperlink. The principle of operation is not yet completely clear.
  • element area now has hreflang and rel attributes
  • base got the target attribute
  • attribute value For li and attribute start for element ol no longer deprecated
  • meta received attribute charset
  • new attribute autofocus can be determined by input(except in cases where type attribute - hidden), select, textarea And button. This provides a way to transfer control to the form while the page is loading
  • attribute form For input, output, select, textarea, button And fieldset allows you to associate an element with more than one form
  • input, button And form got the attribute replace, which determines what happens to the element after the form is submitted
  • form, select And datalist have an attribute data, which takes into account automatic pre-filling in case of filling with data from the server
  • new attribute required applies to input(except in cases where type attribute - hidden, image or button) and textarea. It indicates required fields
  • input And textarea have a new attribute inputmode which gives a hint user interface regarding what data is expected to be entered
  • now you can disable(disable) whole at once fieldset what was not possible before
  • element input has several new attributes for defining constraints: autocomplete, min, max, pattern And step, and also list, which can be used together with elements select And datalist
  • input And button also got a new attribute template, which can be used for repetition patterns
  • element menu has three new attributes: type, label And autosubmit
  • script has a new attribute async, which affects the loading and execution of the script
  • element html has a new attribute manifest, which points to an application cache used in conjunction with the API for standalone Web applications
Several attributes from HTML 4 apply to all elements, which is why they are called global attributes: class, dir, id, lang, tabindex And title.

There are also several new global attributes:

  • attribute contenteditable indicates that the element is editable
  • contextmenu can be used to point to a context menu created by the author
  • draggable can be used in conjunction with the new drag&drop API
  • irrelevant indicates that the element is not yet or no longer relevant
Attributes for the repetition model:
  • repeat
  • repeat-start
  • repeat-min
  • repeat-max

Canceled Items

The following elements are not included in HTML 5 because their effect is achieved using CSS:
  • basefont
  • center
  • strike
The following elements were not included in HTML 5 because their use had a negative impact on usability and accessibility:
  • frame
  • frameset
  • noframes
The following items are not included because they were rarely used or they may have been replaced by other items:
  • acronym
  • applet replaced object
  • isindex
  • dir replaced ul
Finally noscript remained only in HTML syntax, since its use involves parsing with using HTML parser.

Canceled Attributes

  • accesskey For a, area, button, input, label, legend And textarea
  • rev And charset For link And a
  • shape And coords For a
  • longdesc For img And iframe
  • target For link
  • nohref For area
  • profile For head
  • version For map, img, object, form, iframe, a
  • scheme For meta
  • archive, classid, codebase, codetype, declare And standby For object
  • valuetype And type For param
  • charset And language For script
  • summary For table
  • headers, axis And abbr For td And th
  • scope For td
Additionally, HTML 5 does not have the following attributes because they are handled better by CSS:
  • align For caption, iframe, img, input, object, legend, table, hr, div, h1-h6, p, col, colgroup, tbody, td, tfoot, th, thead, tr And body
  • alink, link, text And vlink For body
  • background For body
  • bgcolor For table, tr, td, th And body
  • border For table, img And object
  • cellpadding And cellspacing For table
  • char And charoff For col, colgroup, tbody, td, tfoot, th, thead And tr
  • clear For br
  • compact For menu, ol And ul
  • frame on table
  • frameborder attributed to iframe
  • height For iframe, td And th
  • hspace And vspace For img And object
  • marginheight, marginwidth And scrolling For iframe
  • noshade For hr
  • nowrap For td And th
  • rules For table
  • size For hr, input And select
  • style for all elements
  • type For li, ol And ul
  • valign For col, colgroup, tbody, td, tfoot, th, thead And tr
  • width For hr, table, td, th, col, colgroup, iframe And pre

API

HTML 5 introduces many APIs that should help you create Web applications. They can be used together with new elements.
  • 2D drawing API that can be used with the new element canvas
  • Video and audio playback API that can be used with new elements video And audio
  • allocated memory area (Persistent storage) with data support in the form of key/value and SQL data
  • API that allows autonomous operation web applications
  • An API that allows web applications to register themselves for specific protocols or MIME types
  • Editing API combined with the new global contenteditable attribute
  • Drag&drop API in combination with attribute draggable
  • Network API
  • An API that builds a browsing history to prevent the back button from breaking (This API has the necessary security restrictions)
  • Cross-document messaging
  • Server-sent events combined with a new element event-source

HTMLDocument extension

HTML 5 extended the HTMLDocument interface. The interface is now implemented on all Document interface objects. His new methods:
  • getElementsByClassName()
  • activeElement And hasFocus
  • getSelection()
  • designMode And execCommand(), which are used primarily for document editing

Extension to HTMLElement

The HTMLElement interface also received several extensions:
  • getElementsByClassName()
  • innerHTML
  • classList introduced for ease of access to className. The returned object has methods has(), add(), remove() And toggle() to manipulate element classes
Based on

HTML5 has attracted a lot of attention from web developers. And so the differences between HTML5 and its predecessors.

The new features of this standard are intended for creating interactive web applications with maximum use multimedia content, working with software interfaces and document structuring. language interactive web application

The structural capabilities of HTML5 make the structure of a web document simpler and clearer, and the code is much cleaner. Instead of the div containers used in HTML 4.01, you can use tags such as header, nav, section, article, aside, and footer.

New elements allow you to better describe headers, footers, site blocks, text, and other parts of a website. These innovations are used to generate a table of contents and organize more efficient and easy navigation on a web page, without cluttering the code with other unimportant tags. Here are some examples:

Example 1: Instead of the cumbersome HTML4.01 notation:

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

in HTML5 it will look much shorter:

.Example 2: In HTML4, the following code is needed to create a header: