HTML COURSE โ€ข LESSON 5

HTML Attributes

HTML attributes provide additional information about HTML elements.

Attribute Syntax

Attribute Structure
<tag attribute="value">
    Content
</tag>

Attributes are normally written inside the opening tag.

The href Attribute

The href attribute tells a link where to go.

href Attribute
<a href="https://eduhubsl.com">
    Visit EDUHUB
</a>

The src Attribute

The src attribute specifies the location of an image.

src Attribute
<img src="student.jpg">

The alt Attribute

The alt attribute provides alternative text if an image cannot be displayed.

alt Attribute
<img
    src="student.jpg"
    alt="Student learning HTML"
>

The style Attribute

The style attribute can add CSS directly to an element.

style Attribute
<p style="color: cyan;">
    EDUHUB Code Hub
</p>

The title Attribute

The title attribute can display additional information when the user places the mouse over an element.

title Attribute
<p title="Learn HTML with EDUHUB">
    Move your mouse here.
</p>
โš  Best Practice

Always place attribute values inside quotation marks.

โšก EDUHUB Live HTML Editor

LIVE PREVIEW