HTML base elements

HTML DOCTYPE

The first line of an HTML document is the Doctype declaration. This is used to tell the browser what version of HTML you are using. DOCTYPEs are required for legacy reasons. HTML is responsible for informing the browser how text and objects will appear in the web page. DOCTYPE declaration is not an HTML tag. It is only a declaration and always appears at the first line of your HTML documents. There are a number of different doctype declarations that correspond to various versions of HTML.

HTML5 – does not have a formal DTD (Document Type Definition) in the form of a URL or other Formal Public Identifier

<!DOCTYPE html>

HTML 4.01 Strict – Does not allow Framesets, presentational or deprecated elements

<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

etc …


HTML lang attribute

You can provide HTML Language Code Reference.

ISO Language Codes – The HTML lang attribute is used to declare the language of the web page, used by search engines and the browser. It is best practice to provide the primary language on the lang attribute on the root HTML tag.

In HTML5, the lang attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).

In HTML 4.01, the lang attribute cannot be used with: <base>, <br>, <frame>, <frameset>, <hr>, <iframe>, <param>, and <script>.

<html lang="en">
  ...
</html>

In XHTML, the language is declared inside the html tag as well


<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...
</html>

You can find a list of the language codes here


HTML HEAD element

The <head> element is a container for all the head elements.

The <head> element can include a title for the document, scripts, styles, meta information, and more.

The following elements can go inside the <head> element:

<title> (this element is required in an HTML document)
Defines the Title in the browser tab
Used as the title when added to favorites
Displayed as the title in search engine results

<style>
Used to define style information for the HTML page. CSS

<base>
specifies the base URL and base target for all relative URLs in a page

<link>
Used to link external resources and stylesheets

<meta>
used to specify which character set is used, page description, keywords, author, and other metadata.

<script>
used to define client-side JavaScripts.

<noscript>
defines an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support script.

In HTML 4.01, the head element is required,
In HTML5 it may be omitted.