2 min read · Free · No login needed
Attributes give extra information about an element. They always sit inside the start tag, in the form name="value". The value is usually written inside double quotes.
href — the address a link goes to: <a href="https://kamaldnp.com">Visit us</a>src — the file an image or script loads: <img src="photo.jpg">alt — text shown if an image cannot load, and read by screen readers.width and height — the size of an image in pixels.title — a small tooltip that appears when the mouse hovers over the element.style — CSS written directly on the element.Always put attribute values in quotes. Double quotes are the standard. Single quotes also work, but mixing them or leaving them out causes bugs — especially when the value itself contains spaces. For example, href=https://kamaldnp.com without quotes may work, but title=My Photo without quotes breaks, because the browser reads only My as the value.
Almost every HTML element accepts the global attributes — id, class, style, and title. You will use id and class constantly when you start styling pages with CSS, so remember them now.
href, not HREF.<!DOCTYPE html>
<html>
<head>
<title>Attributes</title>
</head>
<body>
<a href="https://kamaldnp.com" title="Visit KAMALDNP">KAMALDNP Academy</a>
<p><img src="logo.png" alt="KAMALDNP logo" width="120" height="120"></p>
</body>
</html>
test.html, open it in your browser, and change the text to see what happens. That is how you learn — by changing things and watching the result.Finish all 30 lessons, pass the test (80%), pay ₹10 and get your certificate.
Take the testFree tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.
Browse all coursesAsk about courses, website & more
Request human callback:
Download karne ke liye login karo. Login ke baad yahi page pe rahoge!
Naya ho? Register karo →