FOLLOW US ON TWITTER



FOLLOW US



img/blogimg/html5.jpg


@harish 1045

What is a void element in HTML?


2021-11-17 21:21 · 4 min read

Not all HTML tags are of the same structure. While most elements require an opening tag, a closing tag, and contents, some elements - known as void elements - only require an opening tag as they themselves do not contain any elements. This topic explains and demonstrates the proper usage of void elements in HTML

Void elements

HTML 4.01/XHTML 1.0 Strict includes the following void elements:

  • area - clickable, defined area in an image
  • base - specifies a base URL from which all links base
  • br - line break
  • hr - horizontal rule (line)
  • img - image
  • input - field where users enter data
  • link - links an external resource to the document
  • meta - provides information about the document
  • param - defines parameters for plugins

HTML 5 standards include all non-deprecated tags from the previous list and

  • command - represents a command users can invoke [obsolete]
  • keygen - facilitates public key generation for web certificates [deprecated]
  • source - specifies media sources for picture, audio, and video elements
     

The example below does not include void elements:

<div>
<a href="http://blog.theprodevelopers.com/">
<h3>Click here to visit <i>Pro Developer</i></h3>
</a>
<button onclick="alert('Hello!');">Say Hello!</button>
<p>My favorite language is <b>HTML</b>. Here are my others:</p>
<ol>
<li>CSS</li>
<li>JavaScript</li>
<li>PHP</li>
</ol>
</div>

Notice how every element has an opening tag, a closing tag, and text or other elements inside the opening and closing tags. Void tags however, are shown in the example belows:

<img src="https://blog.theprodevelopers.com/img/logos/logo.png" />
<br>
<hr>
<input type="number" placeholder="Enter your favorite number">

With the exception of the img tag, all of these void elements have only an opening tag. The img tag, unlike any other tag, has a self closing / before the greater than sign of the opening tag. It is best practice to have a space before the slash.

 

TAGS:






POST COMMENTS
No Comment

Please login to post comment




POPULAR POSTS

best free web hosting services...
what is new in miui 11?...
free website ssl security using cloudfla...
do you want to make money online?...
CSS3 @IMPORT RULES...
What is HTML Anchor Tag and Hyperlinks?...
CSS3 RESPONSIVE UI...
How to host a web page in 10 minutes....
Tables HTML...
CSS3 FUNCTIONS...
How to use CSS3 Overflow Property?...
CSS3 FILTERS...


RECENT COMMENTS

2022-03-05 11:05
By coder on XAMPP - MySQL shutdown unexpectedly | How to fix MySQL crash unexpectedly
2021-10-12 12:34
By abnongoke on do you want to make money online?
2021-10-12 12:34
By abnongoke on how to get a free website domain name?
2021-10-12 12:34
By solar panel for shed on what is new in miui 11?
2021-10-12 12:34
By solar panel for shed on best free web hosting services
2021-10-12 12:34
By amos tanui on free website ssl security using cloudflare


SOCIAL SHARE



FOLLOW US ON TWITTER



FOLLOW US ON FACEBOOK



FOLLOW US







Recent Blogs



Contact Us

Subscribe Our News-Letter



Kashipur, 244713
Uttarakhand, India



© blog.theprodevelopers.com 2024. All Rights Reserved. Powered by Pro Developer