Websites

HTML Attributes Explained: id, class, src, href (Video)

Watch our lesson on HTML attributes: what they are and how to use id, class, src, href, alt, style and placeholder, with examples.

AMAMJAM Solutions teamRewari, Haryana 2 Oct 20253 min read
On this page

    Attributes give HTML elements extra information, such as where a link goes or which image to show. The video (in Hindi) covers the most common ones; here is a quick reference.

    How attributes are written

    <a href="https://example.com" class="btn">Visit</a>

    Attributes go inside the opening tag, as name="value" pairs, separated by spaces.

    Common attributes

    AttributeUsed onWhat it does
    hrefa, linkThe address a link points to
    srcimg, script, iframeThe file to load
    altimgText describing the image, for screen readers and search engines
    idanyA unique name for one element
    classanyA reusable name for styling groups of elements
    styleanyInline CSS for one element
    placeholderinput, textareaHint text shown in an empty field
    titleanyExtra information shown on hover
    targetaWhere to open the link, such as a new tab

    Tips

    • Always quote attribute values.
    • Each id must be unique on the page; classes can repeat.
    • Prefer classes and a stylesheet over inline style attributes.
    • Encode special characters in URLs; our URL encoder does it for you.
    • Small images can be embedded directly in src with our image to Base64 tool.

    Want the full picture? This article is part of Business websites: the complete guide, our in-depth guide with everything in one place.

    AM
    Written by the AMJAM Solutions team

    Our specialists handle a new website for businesses across India from our office in Rewari. We update our articles as platforms change.

    Free strategy call

    Find out where your next customers will come from

    Tell us a little about your business. We'll set up a 15-minute call and come prepared with first ideas.

    • No obligation and no sales script
    • Speak with a strategist, not a call centre
    • Leave with at least one thing you can act on

    We use your details only to arrange this call. See our privacy policy.

    Get a free 15‑minute strategy call

    Leave your details and a strategist will call you, usually the same working day.

    We use your details only to reply. See our privacy policy.