0% found this document useful (0 votes)
8 views

HTML Elements and Attributes

Uploaded by

velavannithi07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

HTML Elements and Attributes

Uploaded by

velavannithi07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

HTML Elements and Tags:


Understanding HTML Elements and Their
Structure
HTML (HyperText Markup Language) is the
standard language for creating web pages
and web applications. HTML elements
are the building blocks of HTML pages.
Each element typically consists of a start
tag, content, and an end tag.
a. HTML Elements
An HTML element generally follows this
structure:

• Start Tag: <tagname> - This indicates the


beginning of an element. It’s enclosed in
angle brackets.
• Content: This is the information or content
that is enclosed by the tags.
• End Tag: </tagname> - This indicates the end
of an element. It is similar to the start tag but
with a forward slash before the tag name.
Example:

• <p> is the start tag.


• This is a paragraph element. is the content.
• </p> is the end tag.
b. Empty Elements
Some elements don’t have any content and
are known as empty elements or self-
closing tags. They only have a start tag
and no end tag.
Example:
2. Attributes: Global Attributes and
Element-Specific Attributes
Attributes provide additional information
about HTML elements. They are always
included in the start tag and typically
come in name/value pairs like
name="value".
a. Global Attributes
Global attributes are standard attributes
that can be used with any HTML element.
• id: A unique identifier for the element. Used
for styling with CSS or for targeting with
JavaScript.


• class: A class name or space-separated list of
class names that can be used to style multiple
elements.

• style: Used to apply inline CSS styles to an


element.

• title: Provides additional information about


the element. This often appears as a tooltip
when the mouse hovers over the element.

• data- attributes*: Used to store custom data


within an element. Useful for storing
information to be processed by JavaScript

b. Element-Specific Attributes
Certain attributes are specific to particular
elements.
• src (for <img>, <script>, <iframe>, etc.):
Specifies the source of an embedded
resource like an image or script.

• href (for <a>): Specifies the URL of the page


the link goes to.

• alt (for <img>): Provides alternative text for


an image if it cannot be displayed.


• type (for <button>, <input>, <script>, etc.):
Specifies the type of element, such as the
type of button or input.

You might also like