Elements

HTML

HTML Examples



Html Elements


Html documents are defined by Html elements.The page heading texts, the paragraph texts, the images, and the navigation links are all elements of the web page. A single page can contain hundreds or thousands of elements. Every Html page should have a bare minimum of four critical elements: the html, head, title, and body elements. An element consists of three essential pieces: an opening tag, the content, and a closing tag. Some Html elements might display correctly even if you forget the end tag. But don't forget the end tag, cause Many Html elements will produce unexpected results and/or errors if you forget the end tag. Html elements with no content are called empty elements.







The <!DOCTYPE> Declaration


There are many different documents on the web, and a browser can only display an Html page 100% correctly if it knows the Html type and version used. Before an opening <html> tag, an XHTML document can contain the optional XML declaration, and it should always contain a DOCTYPE declaration indicating which version of XHTML it uses.







Common Declarations



HTML 5

<!DOCTYPE html>







HTML 4.01

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









The <html> Element


"Html tags" and "Html elements" are often used to describe the same thing. <html> is the element that begins and ends each and every web page. Its describe documents as Html document andhold each web element nicely in position and serves the role of book cover.







The <head> Element


The <head> element is just a container for all header information of a web page. It should be the first thing to appear after the opening <html> tag. These elements are not directly displayed by a web browser. Instead they function behind the scenes, providing more descriptive information about the Html document, like its page title and other meta data. Other elements used for scripting (JavaScript) and formatting (CSS) are also contained within the <head> element.







The <title> Element


The <title> element adds a title to a web page. Web page titles are displayed at the top of any browser window or at the top of browser tabs. This element is a child of the <head> element.







The <body> Element


The <body> element appears after the <head> element and contains the part of the Web page that actually see in the main browser window, which contains the visual elements like headings, paragraphs, pictures, tables etc.







Html Document Example




<!DOCTYPE html>


<html>


 <head>


   <title> My first page </title>


 </head>


 <body>


   <h1> This is my first heading </h1>


   <p> This is my first paragraph. </p>


 </body>


</html>