HTML Attributes
Published: Tuesday, November 4, 2003
 | What are HTML Attributes? HTML elements can have associated properties known as attributes. Attributes are added to an element as name-value pairs before the closing '>' of the element's start tag. An attribute consists of 2 parts - a name (e.g. face) and a value (e.g. Arial). Example: <img src="/images/logo.gif" alt="Logo" width="400" height="300"> In the above example, there are 4 attributes of the image element. The name of these attributes are src, alt, width and height. The corresponding values are /images/logo.gif, Logo, 400 and 300.
- Any number of (legal) attributes can be added to an element.
- Attributes are added in the name="value" format.
- Attributes are separated by spaces.
- Attribute names are not case sensitive.
- It is a good coding practice to enclose attribute values within double quotes (").
- If quotes are not used, values can consist of letter (a-z and A-Z), digits (0-9),
hyphens and periods.
|
 | Some commonly used HTML attributes Here is a list of commonly used attributes. align : Alignment attribute - Aligns the element in horizontal direction.
Values - left | center | right
Some related elements - <img>, <input>, <table>, <hr>, <th>, <td>, <tr>, <iframe>.
valign : Vertical Alignment attribute - Aligns the element in vertical direction.
Values - top | middle | baseline | bottom
Some related elements - <th>, <td>, <tr>, <tbody>.
width : Width attribute - Specifies the width of an element.
Values - pixels | % of parent width
Some related elements - <table>, <hr>, <iframe>, <img>, <td>, <th>.
height : Height attribute - Specifies the height of an element.
Values - pixels | % of parent height
Some related elements - <table>, <hr>, <iframe>, <img>, <td>, <th>.
size : Width attribute - Specifies the width of an element.
Values - pixels | % of parent cell
Some related elements - <table>, <hr>, <iframe>, <img>, <td>, <th>.
face : Face attribute - Sets the face of a font attribute. Font faces are specified as comma-separated list. The font element attributes may not be supported in future HTML versions (deprecated). W3C recommends using style sheets for formatting instead of HTML formatting attributes.
Some values - Arial | Verdana | Helvetica
Related elements - <font>, <basefont>.
|
|
|
RELATED ARTICLES
|
 |
HTML Tutorial - Introduction
HTML stands for Hyper Text Markup Language. It is the publishing language of the World Wide Web (WWW). Learn about HTML in this tutorial.
|
|
|
|
RELATED NEWS
|
 |
Equifax Secures 27 New Patents in the Second Half of 2025
20 Patents Support the Organization's Approach to Responsible AI, Designed to Accelerate Product Innovation that Help to...
|
 |
Discover MiniTool's New Screen Recorder: The Perfect Solution for All Your Recording Needs
VANCOUVER, BC, Dec. 24, 2025 /PRNewswire/ -- MiniTool Software Limited has unveiled a new screen recording software : MiniToo...
|
 |
Thoughtworks Recognized as a Visionary in 2025 GartnerĀ® Magic Quadrant(TM) for Custom Software Development Services
CHICAGO, Dec. 11, 2025 /PRNewswire/ -- Thoughtworks , a global technology consultancy that integrates design, engineering and...
|
 |
Microsoft Selects Iron Software as Key .NET 10 Launch Partner for APAC Region, Showcasing C# Generate PDF Innovation at .NET Conf Thailand 2025
Iron Software successfully hosted Microsoft-sponsored virtual event, delivering expert insights on .NET 10 migration, AI-powe...
|
 |
Channel3 Secures $6M Seed Funding to Build the Infrastructure Behind Agentic Commerce
Channel3 provides developers and merchants with a universal product graph for the next generation of commerce NEW YORK, Dec....
|
|
Submit News |
View More News
|
|
|
|
|
|
|