Difference between <!DOCTYPE html> and <html>

Asked

Viewed 44 times

0

I’ve always used both in an HTML code, but I don’t know the real difference between them. Could someone explain to me the difference between and ?

  • @Maniero, the questions you have asked just talk about the functionality of <!DOCTYPE html> or how to write it correctly. However, I already know this. What I’d like to know is the difference between this statement and the <html tag>.

2 answers

1

The <html> itself is a tag to start the file, basically. Despite the similar syntax, Doctype is not an HTML tag. Doctype HTML is a declaration to inform the browser which version of HTML is used in the file. This statement comes before HTML tags, so it is usually presented in the first line of a code. It is recommended that we always use Doctype for the browser to detect the HTML version.

1

General differences between HTML5 and HTML4

  1. Simplified and clear syntax

The syntax in HTML5 is extremely clear and simple compared to HTML4. An example of this is the DOCTYPE element. In HTML4, the DOCTYPE statement was very confusing and time consuming and used to reference an external source. However, the HTML5 DOCTYPE element was made extremely simple. For example, a mere <! DOCTYPE html> is sufficient to specify the document type.

  1. Multimedia elements

HTML5 contains built-in support for multimedia files integrated into the web page through video and audio tags. Previously, in HTML4, multimedia content was integrated into web pages through third-party plugins such as Silverlight and flash.

  1. Accessing the geographic location of the user

Previously in HTML4, it was an extremely complicated task to obtain the geographical locations of visitors visiting the site. It was even difficult when the site was accessed through mobile devices. On the other hand, HTML5 is extremely easy to get the user’s location. HTML5 JS Geolocation can be leveraged to identify the location of the user accessing the site.

  1. Customer side storage

In HTML4, to store important data on the client side, the browser cache was used. However, this cache is limited and does not support the relational storage engine. In HTML5, this problem has been solved through SQL Web database and application cache that can be accessed by the HTML5 Javascript interface.

  1. Communication from the client server

In HTML4, communication between the client and the server was done through streaming and long soundings, as there are no Web sockets available in HTML4. On the contrary, HTML5 contains web sockets that allow full duplex communication between clients and servers.

  1. Javascript chaining mechanism

In HTML4, Javascript and the browser interface with which the user interacts are executed in the same chaining that affects performance. HTML5 contains the JS Worker Web API, which allows the Javascript and Browser interface to run in separate threads.

  1. Browser Compatibility

As mentioned earlier, HTML4 is an established standard for browser application development and has been in use for more than 10 years. For this reason, HTML4 is compatible with almost all web browsers.

inserir a descrição da imagem aqui

HTML4 and HTML5 tag differences

Several HTML4 tags have been removed from HTML5 or their functionality has been modified. The following are some of the tags removed from HTML5 or with different HTML5 features compared to HTML4.

  1. removed <Object> Added in HTML5

HTML4 contained a tag <applet> used to display applets in a web browser. However, in HTML5, this applet tag has been removed. To display items of the applet type, a new tag <object> was introduced in HTML5.

  1. <Acronym> removed <Abbr> Added in HTML5

HTML4 contained a tag <acronym> used to display abbreviations in a web browser. However, in HTML5, this tag has been removed. A new tag <abbr> was introduced in HTML5.

  1. Difference in tag usage <hr>

The tag <hr> was used to draw a line in HTML4 and all previous versions of HTML; however, in HTML5, the functionality of this tag was changed and used to define a theme break on the web page.

  1. Difference in tag usage <a>

In HTML4 and earlier, the tag <a> was used as an anchor and also to refer to a link. In HTML5, the tag <a> is only used as a hyperlink. But if the href tag is removed from the tag <a>, the tag <a> may be used as a space reserved for other hyperlinks.

  1. Schema attribute removed from tag <meta> in HTML5

The tag is defined in the header section of the HTML document and contains information about the data. In previous versions of HTML, including HTML4, this tag used to contain an attribute called schema that defined the document schema. However, in HTML5, this tag has been removed.

Changes in attributes

The following are some of the attributes that have been modified in HTML5.

In previous HTML4 and HTML versions, the script attribute was used in the link tag to refer to Javascript or other similar scripts. In HTML5, it is not necessary to use this script attribute.

In HTML5, the tag <table> may have only one Border attribute and the value of that attribute may be only zero or one. Previously, the tag had many attributes.

In previous versions of HTML, the tag did not have the charset attribute that sets the default character encoding for the web page. This attribute was added in HTML5.

learn more ....

Html5test

Browser other questions tagged

You are not signed in. Login or sign up in order to post.