find and solve || findandsolve.com
Please wait.....

HTML Basic Elements Example

The complete set of HTML elements is the set of elements and  an individual component of an HTML document and represents semantics, or meaning.

The HTML element is everything from the start tag to the end tag:

Basic Elements

An HTML element is defined by a start tag <>, some content, and an end tag </>.There are some basic elements of an HTML page like as given below:

  • <p> : A paragraph, denoted using the tag
  • A text header, denoted using the <h1>, <h2>, <h3>, <h4>, <h5>, <h6> tags
  • <div> : This is division content
  • A horizontal ruler, denoted using the <hr> tag
  • A link, denoted using the (anchor) <a> tag
  • An image, denoted using the <img> tag
  • A text span, denoted using the <span> tag
  • A list, denoted using the <ul> (unordered list), <ol> (ordered list) and <li> (list element) tags
  • An image, denoted using the <img> tag

HTML Element Syntax

An HTML element is an individual component of an HTML document. It represents semantics, or meaning. For example, the title element represents the title of the document.

In HTM most text content  in between start tag and an end tag . Elements can also contain attributes that defines its additional properties. For example, a paragraph, which is represented by the p element, would be written as:



Nested HTML Elements

It is very much allowed to keep one HTML element inside another HTML element.

For example

<!DOCTYPE html>
<html>
   <head>
      <title>Nested Elements Example</title>
   </head>
   <body>
      <h1>This is <b>this iss bold</b> heading</h1>
      <p>This is <em>this is emphasized </em> paragraph </p>
   </body>
</html>

HTML tags should be nested in correct order. They must be closed in the inverse order of how they are defined, that means the last tag opened must be closed first.

<div><strong>These tags are nested properly.</strong></div>
<div><strong>These tags are not nested properly.</p></strong>

Never Skip the End Tag

Some HTML elements will display correctly, even if you forget the end tag:

<html>
<body>
<div>This is a division 
<div>This is a division 
</body>
</html>

Empty HTML Elements

HTML elements with no content are called empty elements and also called self-closing or void elements.That means, you can not write <hr>some content</hr> or <br>some content</br>

A typical example of an empty element, is the <br> element, which represents a line break. Some other common empty elements are <img>, <input>, <link>, <meta>, <hr>, etc.

<div>This division contains section <br> a line break.</p>
<img src="image/file/findandsolve.jpg" alt="find and solve">
<input type="text" name="fullname">

Writing Comments in HTML

Comments are usually added with the purpose of making the source code easier to understand. It may help other developer (or you in the future when you edit the source code) to understand what you were trying to do with the HTML. Comments are not displayed in the browser.

An HTML comment begins with <!--, and ends with -->, as shown in the example below:

<!-- This is an example of  HTML comment -->
<!-- This is a multi-line comment example in HTML 
     that spans across more than one line -->

<p>This is a normal piece of text. which is not commented</p>