HTML attributes provide additional information about HTML elements.
name="value"
The <a>
tag defines a hyperlink. The href
attribute specifies the URL:
<a href="https://www.w3schools.com">Visit W3Schools</a>
The <img>
tag embeds an image. The src
attribute defines the image path:
<img src="img_girl.jpg">
Use width
and height
to define image size:
<img src="img_girl.jpg" width="500" height="600">
The alt
attribute provides alternate text for the image:
<img src="img_girl.jpg" alt="Girl with a jacket">
Add CSS directly using style
attribute:
<p style="color:red;">This is a red paragraph.</p>
Use lang
in <html>
to define page language:
<html lang="en"> ... </html>
lang="en-US"
Shows a tooltip on hover:
<p title="I'm a tooltip">This is a paragraph.</p>
<a href="https://www.w3schools.com/html/">Good</a>
<a href=https://www.w3schools.com/html/>Bad</a>
Sometimes, you must use quotes due to spaces:
<p title='John "ShotGun" Nelson'>
href
defines link URLsrc
defines image pathwidth
and height
define image sizealt
provides alternative textstyle
applies inline CSSlang
defines page languagetitle
shows tooltips