Creating Links & Adding Images in HTML (With Practical Examples)
After learning HTML basics and common tags, the next important step is understanding how to create links and add images to a webpage. These two elements are essential for building real, usable websites.
In this blog, we’ll learn how the <a> (anchor) and <img> (image) tags work, along with practical examples you can try yourself.
Creating Links in HTML (<a> Tag)
The <a> tag is used to create clickable links that take users to another page, website, or location.
Basic Link Example
Important Attributes
-
href→ The destination URL -
Link text → The clickable text users see
Opening Links in a New Tab
To open a link in a new browser tab, use the target attribute:
Use Case
-
External websites
-
References
-
Social media links
Linking to Internal Pages
You can also link to pages within your website:
Use Case
-
Navigation menus
-
Multi-page websites
Email & Phone Links
Email Link
Phone Link
Use Case
-
Contact pages
-
Business websites
Adding Images in HTML (<img> Tag)
The <img> tag is used to display images on a webpage.
It is a self-closing tag.
Basic Image Example
Important Attributes
-
src→ Path to the image -
alt→ Text shown if the image fails to load
Setting Image Width & Height
Use Case
-
Logos
-
Thumbnails
-
Banners
Using Images from a Folder
If your image is inside a folder:
Best Practice
Keep images organized inside folders like images/ or assets/.
Making an Image Clickable
You can wrap an image inside a link:
Use Case
-
Advertisement banners
-
Clickable logos
Why alt Text Is Important
The alt attribute:
- Helps screen readers
- Improves SEO
- Displays text if image fails to load
Always write meaningful alt text.
Common Mistakes to Avoid
- Missing
altattribute - Incorrect file path in
src - Using very large image files
- Opening all links in new tabs unnecessarily
Conclusion
Links and images bring life to a webpage. Using the <a> and <img> tags correctly allows you to:
-
Connect pages
-
Navigate users
-
Display visual content
-
Build real-world websites
Once you master these tags, you’re ready to move into CSS styling and layouts.
Comments
Post a Comment