HTML Uniform Resource Locators (URL)

URL क्या होता है?

URL (Uniform Resource Locator) इंटरनेट पर किसी भी resource का पूरा address होता है।
HTML में URL का उपयोग web pages, images, videos, files और other resources को access करने के लिए किया जाता है।

सरल शब्दों में, URL बताता है कि
resource कहाँ है
और उसे कैसे access करना है

HTML में URL कहाँ इस्तेमाल होता है?

HTML में URLs कई attributes में use होते हैं।

<a href="https://example.com">Visit Site</a>
<img src="image.jpg">
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>

URL की Basic Structure

एक complete URL आमतौर पर इन parts से मिलकर बनता है।

scheme://domain:port/path?query#fragment

Example:

https://www.example.com:443/blog/post?id=10#comments

URL के मुख्य Parts

Scheme बताता है कि resource को किस protocol से access करना है।
Common schemes हैं http, https, ftp, mailto.

https://

Domain server का नाम होता है जहाँ resource मौजूद है।

www.example.com

Path server के अंदर resource की location बताता है।

/blog/post

Query extra data भेजने के लिए use होती है।

?id=10

Fragment page के किसी specific section को target करता है।

#comments

Absolute URL

Absolute URL में पूरा address लिखा होता है।

<a href="https://www.example.com/about.html">About</a>

इसमें scheme, domain और path सभी शामिल होते हैं।

Relative URL

Relative URL current page के location के आधार पर लिखा जाता है।

<a href="about.html">About</a>
<img src="images/logo.png">

Relative URLs छोटे और portable होते हैं।

Root Relative URL

Root relative URL website के root folder से start होता है।

<img src="/images/banner.jpg">

यह method large websites में ज्यादा reliable होती है।

URL का उपयोग Anchor Tag में

<a> tag का href attribute URL define करता है।

<a href="https://google.com">Google</a>

URL का उपयोग Image में

Images load करने के लिए src attribute में URL दिया जाता है।

<img src="photo.jpg" alt="Sample Photo">

URL का उपयोग CSS और JavaScript में

CSS file link करने के लिए:

<link rel="stylesheet" href="style.css">

JavaScript file include करने के लिए:

<script src="app.js"></script>

Mailto URL

Email open करने के लिए mailto scheme use होती है।

<a href="mailto:info@example.com">Send Email</a>

Telephone URL

Phone call initiate करने के लिए tel URL use किया जाता है।

<a href="tel:+911234567890">Call Now</a>

URL Encoding का Concept

कुछ characters URLs में directly allowed नहीं होते।
ऐसे characters को encoded form में लिखा जाता है।

Space  →  %20

Example:

<a href="my%20file.html">My File</a>

Secure URLs (HTTPS)

https secure protocol होता है जो data को encrypt करता है।
Modern websites के लिए HTTPS mandatory माना जाता है।

https://example.com

URL Best Practices

Simple और readable URLs रखें
Spaces और special characters avoid करें
HTTPS का उपयोग करें
Relative URLs जहाँ possible हों वहाँ use करें

HTML Uniform Resource Locators Summary

URL resource का complete address होता है
HTML में URLs links, images और files के लिए use होते हैं
Absolute और Relative URLs दोनों के अपने use cases हैं
HTTPS secure और recommended protocol है

Share your love