HTML Elements

Admin
0

In this chapter, you will learn everything you need to know about HTML elements, their structure, and how they build web pages.


What is HTML Element?

An HTML element is a fundamental building block of an HTML document used to build webpages.

HTML elements are begin with a a opening tag, optionally includes some content, and ends with a closing tag.

HTML Elements can represent various types of content, such as text, images, links, and other multimedia.

An HTML element is everything from the start/opening tag to the end/closing tag.

HTML Element Syntax:

<tagname>Some content here</tagname>

Start/Opening tag: Marks the beginning of an element (e.g., <p>).

Content: The text or other elements inside the tags.

End/Closing Tag: Marks the end of an element (e.g., </p>).

Example

<p>Hallo, World!</p>

Here, <p> is the paragraph element. The browser renders the text "Hello, World!" inside a paragraph.


Types of HTML Elements

1. Block-Level Elements

Block-level elements take up the full width of their container and always start on a new line.

Key Fetures

Used to structure large sections of content.

Can contain other block-level or inline elements.

Block-level Element Examples

<div>: Generic container for content.

<p>: Defines a paragraph.

<h1> to <h6>: Represents headings of different levels.

<ul> and <ol>: Defines unordered and ordered Lists.

<table>: Defines tables.

Try It Yourself

2. Inline Elements

Inline elements are used within block-level elements to style or define smaller parts of content. They do not start on a new line and only take up as much width as necessary.

Key Features:

Used for styling or linking.

Cannot contain block-level elements.

Inline Element Examples

<span>: Generic container for inline content.

<a>: Defines a hyperlink.

<strong>: Highlights text with bold emphasis.

<em>: Highlights text with italic emphasis.

<i>: Used to style text in italics.

<ui>: Used to underline text.

Try It Yourself

3. Void (Empty) Elements

Void elements do not have closing tags or inner content. They are self-contained and often used for metadata or standalone items.

Key Features:

Does not require a closing tag.

Typically includes attributes for functionality.

Examples of Void Elements:

<meta>: Provides metadata for the page.

<img>: Embeds an image.

<br>: Inserts a line break.

<hr>: Adds a horizontal line.

Try It Yourself

Tags

Post a Comment

0Comments
Post a Comment (0)