7.HTML Elements
7.HTML Elements
HTML Elements
An HTML file is made of elements. These elements are responsible for creating web
pages and define content in that webpage. An element in HTML usually consist of a
start tag <tag name>, close tag </tag name> and content inserted between them.
Technically, an element is a collection of start tag, attributes, end tag, content
between them.
Note: Some elements does not have end tag and content, these elements are
termed as empty elements or self-closing element or void elements.
Such as:
Example
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>WebPage</title>
5. </head>
6. <body>
7. <h1>This is my first web page</h1>
8. <h2> How it looks?</h2>
9. <p>It looks Nice!!!!!</p>
10. </body>
11. </html>
1/4
All the content written between body elements are visible on web page.
Void element: All the elements in HTML do not require to have start tag and end tag,
some elements does not have content and end tag such elements are known as Void
elements or empty elements. These elements are also called as unpaired tag.
Nested HTML Elements: HTML can be nested, which means an element can contain
another element.
Block-level element
Inline element
Block-level element:
These are the elements, which structure main part of web page, by dividing a
page into coherent blocks.
A block-level element always start with new line and takes the full width of web
page, from left to right.
These elements can contain block-level as well as inline elements.
Output:
tag, which defines a section in a web page, and takes full width of page.
We have used style attribute which is used to styling the HTML content, and the
background color are showing that it's a block level element.
Inline elements:
Inline elements are those elements, which differentiate the part of a given text
and provide it a particular function.
These elements does not start with new line and take width as per requirement.
The Inline elements are mostly used with other elements.
<a>, <abbr>, <acronym>, <b>, <bdo>, <big>, <br>, <button>, <cite>, <code>, <dfn>,
<em>, <i>, <img>, <input>, <kbd>, <label>, <map>, <object>, <q>, <samp>, <script>,
<select>, <small>, <span>, <strong>, <sub>, <sup>, <textarea>, <time>, <tt>, <var>.
Example:
Output:
3/4
Start tag Content End tag Description
<h1> These are </h1>??.. These elements are used to provide the
...... headings of HTML </h6> headings of page.
<h6>
<div> This is div section </div> This element is used to provide a section
in web page.
4/4