Create QR Code for Your Website in HTML Code
QR codes are a convenient and fast way to share your website. Instead of typing a URL, users can simply scan a code to visit your website. In this blog, we will show you how to create a QR code for your website in HTML code using a simple approach.
What is a QR Code?
A QR Code (Quick Response Code) is a type of barcode that can hold information, such as a website URL. When scanned with a mobile phone or a QR code reader, it instantly directs the user to the website or displays the stored information.
Why Create a QR Code for Your Website?
Creating a QR code for your website makes it easier for people to access your site. Instead of typing a long URL, they can simply scan the code. This is especially useful in:
- Marketing Materials: Flyers, business cards, and brochures
- .Events: Make it easy for attendees to visit your site.
- Promotions: Share special offers or discounts directly.
Steps to Create a QR Code for Your Website in HTML Code
Step 1: Write the HTML Code
To create a QR code for your website in HTML code, you can use a simple method with Google’s Chart API. Here’s the HTML code to add the QR code to your webpage:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create QR Code for Your Website in HTML Code</title>
</head>
<body>
<h1>Scan the QR Code to Visit My Website</h1>
<img src="https://chart.apis.google.com/chart?cht=qr&chs=500x500&chl=https://phpfortech.com/" alt="QR Code for My Website">
<p>Scan this QR code with your phone to visit my website directly!</p>
</body>
</html>
Step 2: Explanation of the Code
<img>
Tag: This tag is used to display the QR code image on your webpage- .
src
Attribute: It points to the QR code image generated by Google’s Chart API. The URL for your website should replace thechl
parameter (e.g.,https://phpfortech.com/
). alt
Attribute: Describes the QR code image for users who may not see it.
Step 3: Save and Open the HTML File
- Open a text editor like Notepad or Sublime Text.
- Copy and paste the HTML code above.
- Save the file with a
.html
extension, such asqrcode.html
. - Open the file in any web browser to see the QR code displayed.
Conclusion
It’s quick and easy to create a QR code for your website in HTML code. By following these simple steps, you can generate a QR code that lets users scan and instantly visit your website. Whether for personal use or marketing purposes, QR codes are an excellent tool to make your website more accessible.