HTML Attributes
HTML attributes provide additional information about HTML elements.
HTML Attributes
- All HTML elements can have attributes
- Attributes provide additional information about elements
- Attributes are always specified in the start tag
- Attributes usually come in name/value pairs like: name=”value”
The href Attribute
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:
Example
<!DOCTYPE html>
<html>
<head>
<title>
My website>
</title>
</head>
<body>
<a href="https://medium.com"
target ="_blank"
title = "Goes to google">
click me</a>
<br>
<a href = "lyrics.html">
song lyrics
</a>
<br>
<a href="test@fake.com">
email me
</a>
</body>
</html>
Webpage opened in browser and it contains 3 hyperlinks. So after clicking on song lyrics, another webpage opens as it is shown below:
The src Attribute
The <img> tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed:
Example
<!DOCTYPE html>
<html>
<head>
<title>
Dog
</title>
</head>
<body>
<h1>This is a cute dog</h1>
<a href="https://en.wikipedia.org/wiki/Dog">
<img src="images/dog.jfif"
alt="This is a picture of a dog"
height ="200">
</a>
<img src = "images/cutedog.gif"
alt="dog"
height="200">
<h3>woof woof!</h3>
</body>
</html>
This is how a new webpage opens and it displays the images of cute dog.
Let us continue remaining html attributes in the next medium story.
No comments:
Post a Comment