What Is an Empty HTML Element?
An empty HTML element consists of only an opening tag.
In other words, empty HTML elements have no content or closing tag.
Here’s an illustration:
Below are some of the widely used empty HTML elements.
What Is an <img>
Element?
An <img>
element embeds an image to a webpage.
Here’s an example:
Note the following:
src
attribute specifies the image’s URL.- The
width
andheight
attributes specify the image’s dimensions. - An
alt
(alternative text) attribute is essential for accessibility. Browsers display it whenever the image fails to load. And screen readers read it to their users. - Suppose your image is purely decorative. In that case, provide an empty
alt
attribute (alt=""
).
What Is an <input>
Element?
The <input>
element creates an input field for entering data.
Here’s an example: