HTML Elements
HTML Elements are defined by the start tag, attributes, content, and closing tag. Therefore an HTML element is everything from the start tag to the close tag.
HTML Elements are defined by the start tag, attributes, content, and closing tag. Therefore an HTML element is everything from the start tag to the close tag.
My First HTML Heading
My first HTML paragraph.
Example Of HTML Element:
Source Code
<h1>HTML Elements</h1>
<h2>My First HTML Heading</h2>
<p>My first HTML paragraph.</p>
HTML element has either block-level or inline-level. Block-level HTML element takes full available width and starts with a new line and leaves the top and bottom margin while as inline element takes only as much space as it needs. But, both types of elements can be interchanged by CSS rule means a block-level element can be changed to an inline element and an inline element can be changed to block-level by CSS display
property.
HTML elements can be nested means more than HTML elements can be put inside a single HTML element.
Here is some bold text.
Here is some emphasized text.
Here is some highlighted text.
Example of nested HTML elements:
Source Code
<p>Here is some <b>bold</b> text.</p>
<p>Here is some <em>emphasized</em> text.</p>
<p>Here is some <mark>highlighted</mark> text.</p>
Attention!!Here,HTML element <b>
,<em>
as well as <mark>
exists with in <p>
element.
The HTML comment is very useful for understanding the source code. It provides help to understand the source code by another developer. Please keep in mind that HTML comment does not display by browser.
General syntax for writing HTML comment:
HTML comment can be written inside
Source Code
<!--<p>This is paragraph element that is commented.</p>-->
<p>HTML commented code does not display by the browser.</p>
Note:-Please keep in mind that ,HTML element is commented by following syntax <!-- HTML Code Inside --->
.
Source Code
<!--
<p>Here is some <b>bold</b> text.</p>
<p>Here is some <em>emphasized</em> text.</p>
<p>Here is some <mark>highlighted</mark> text.</p>
-->
<p>
The above statement is a multi-line commented statement that does not display by the browser.
</p>
Note-Write multi line HTML code comment can be done by <!-- your multi line html code -->
statement.
The HTML element has either block-level or inline-level. Block-level HTML element takes full available width and starts with a new line and leaves the top and bottom margin while as inline element takes only as much space as it needs. But, both types of elements can be interchanged by CSS rule means a block-level element can be changed to an inline element and an inline element can be changed to block-level by CSS display
property.
Followings are the list of block-level element:
,
,, ,
,
,
,
, , , - ,
Source Code
<p>HTML paragraph element is a block level element & it takes full available width.</p>
Note:HTML block-level element takes full available width while inline takes as necessary as required.
Source Code
<span>Username:</span>
<input type="text" name="username" id="username" />
The Inline element does not take full available and it also does not start with a new line.
HTML empty element does not have content and it is used without closing tag. Followings are the example of empty HTML elements.
, , , ,
,
,etc.
Please keep in mind that, according to above mention the concept, you could not write like this.
<hr>
some content </hr>
or <br>
some content </br>
.
Source Code
<p>This paragraph contains <br /> a line break.</p>
<img src="https://picsum.photos/200/300" alt="image" />
<input type="text" name="username" id="username" />
HTML tags are not case sensitive: <B>
means the same as <b>
.