The DOCTYPE element defines the document type of the file, as follows:
<!DOCTYPE documentType>
The documentType
attribute that you can see in the preceding code lets the browser know the type of document you will use.
HTML5 has a simple document type declaration, <!DOCTYPE html>
. This lets the browser know that the document is HTML5. The previous versions of HTML needed a formal definition of the version being used, but HTML5 has removed this for simplicity.
Most browsers will enforce strict adherence to the document type declared and try and figure out what it is based on looking at the document. This can lead to rendering issues, so it is recommended that you do follow the standards.
Here is an HTML5 declaration:
<!DOCTYPE html>