HTML Elements || Bcis Notes

HTML Elements:-

An HTML element is 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 as shown below with few tags:-

There are some HTML elements which don’t need to be closed, such as <img…/>, <hr /> and <br /> elements. These are known as void elements.

HTML elements with no content are called empty elements. Empty elements do not have an end tag, such as the <br> element (which indicates a line break).

Nested HTML Elements:-
It is very much allowed to keep one HTML element inside another HTML element.HTML elements can be nested (elements can contain elements).

CODE:

Result:-

Example Explained:-
The <html> element defines the whole document.

It has a start tag <html> and an end tag </html>.

Inside the <html> element is the <body> element.

 

The <body> element defines the document body.

It has a start tag <body> and an end tag </body>.

Inside the <body> element is two other HTML elements: <h1> and <p>.

 

The <h1> element defines a heading.

It has a start tag <h1> and an end tag </h1>.

The element content is “BCIS Notes”.

 

 

 

The <p> element defines a paragraph.

It has a start tag <p> and an end tag </p>.

The element content is”This page provides notes of each subjects”.

 

Do Not Forget the End Tag
Some HTML elements will display correctly, even if you forget the end tag:

CODE

 

Result:

The example above works in all browsers, because the closing tag is considered optional.

Never rely on this. It might produce unexpected results and/or errors if you forget the end tag.

 

Empty HTML Elements:-

HTML elements with no content are called empty elements. <br> is an empty element without a closing tag (the <br> tag defines a line break):

CODE:

Result:-

 

 

 

 

 

 

 

Empty elements can be “closed” in the opening tag like this: <br />.

 

HTML Is Not Case Sensitive:-
HTML tags are not case sensitive: <p> means the same as <p>.The HTML5 standard does not require lowercase tags, but W3C recommends lowercase in HTML and demands lowercase for stricter document types like XHTML.

 

You may also like: HTML Editor

Leave a Comment

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