HTML elements

      No Comments on HTML elements

HTML elements are defined by a starting tag. If the element contains other content, it ends with a closing tag, where the element name is preceded by a forward slash.
<tagname>content here…….</tagname>

 Start tag content end tag
 <h1> heading 1 </h1>
 <div> division 1 </div>
 <a> link text </a>
 <br/>

HTML Tags vs Elements

An HTML element is defined by a starting tag. If the element contains other content, it ends with a closing tag.

For example <p> is starting tag of a paragraph and </p> is closing tag of the same paragraph but <p>This is paragraph</p> is a paragraph element.

Nested elements

HTML allows one to put one tag within other called nesting of tags.For example:

<html>
<head>
</head>
<body>
<div>
<p><a href="scanfcode.com">Link</a></p>
</div>
</body>
</html>

Block level and Inline HTML elements

HTML elements can be divided into two parts namely, block level elements and inline elements.

Block level elements are those elements that always begin from a new line. They take up entire width of the parent element. Various block level elements are:

  • <div></div>
  • <p></p>
  • <h1></h1>…..</h6></h6>
  • <form></form>
  • <ul></ul>
  • <ol></ol>
  • <hr/>
  • <dl></dl>
  • <pre></pre>
  • <address></address>
  • <blockquote></blockquote>

For example:

<html>
<head>
</head>
<body>
<div>
<h4>Describing block level elements</h4>
<p>Paragraph 1</p>
<hr><p>Paragraph2</p>
</div>
</body>
</html>

 

Describing block level elements

Paragraph 1


Paragraph 2

Inline elements are those elements do not begin with a new line.Various inline elements are:

  • b, big, i, small, tt
  • abbr, acronym, cite, code, dfn, em, kbd, strong, samp, var
  • a, bdo, br, img, map, object, q, script, span, sub, sup
  • button, input, label, select, textarea.

For example:

<html>
<head>
</head>
<body>
<button>click me</button>
<b>bold 1</b>
<a>link</a>
<img src="Scanfcode.png" alt="scanfcode"/>

bold 1 linkHTML elements

Structure

<html>...</html>

The root element of an HTML document; all other elements are contained in this.
The HTML element delimits the beginning and the end of an HTML document.
Standardized in HTML 2.0; still current.

<head>...</head>

Container for processing information and metadata for an HTML document.
Standardized in HTML 2.0; still current.
(See document head elements for child elements.)

<body>...</body>

Container for the displayable content of an HTML document.
Standardized in HTML 2.0; still current.

Leave a Reply

Your email address will not be published. Required fields are marked *