नमस्कार दोस्तों!
अगर आप वेब डिज़ाइन सीख रहे हैं, तो CSS Background Properties in Hindi आपके लिए एक बहुत जरूरी टॉपिक है। ये CSS की वो property है जो आपकी वेबसाइट के किसी भी HTML element के बैकग्राउंड से जुड़ी होती है।
तो चलिए दोस्तों, आज हम आसान हिंदी में समझेंगे कि CSS Background Property क्या होती है और इसे कैसे इस्तेमाल किया जाता है।
1. CSS Background Properties in Hindi क्या होती हैं?
CSS background property का इस्तेमाल किसी HTML element के बैकग्राउंड का रंग, इमेज, पोजीशन, साइज, अटैचमेंट और रिपीट बिहेवियर को define करने के लिए किया जाता है। ये आपकी वेबसाइट की विजुअल प्रेजेंटेशन को बेहतर बनाता है।
2. CSS Background Properties in Hindi क्यों ज़रूरी हैं?
- Website को visually attractive बनाती है।
- User experience को बेहतर करती है।
- Branding और design consistency बनाए रखती है।
- User engagement को बढ़ावा देती है।
3. CSS Background Properties in Hindi की Important Properties
• background-color क्या होता है?
यह property किसी element का background color सेट करती है।
div {
background-color: lightblue;
}
• background-image क्या होता है?
यह property किसी image को background के रूप में सेट करती है।
div {
background-image: url("image.jpg");
}
• background-repeat क्या करता है?
इससे background image के repeat होने का behavior कंट्रोल होता है।
div {
background-repeat: no-repeat;
}
• background-position कैसे काम करता है?
इससे background image की position सेट होती है।
div {
background-position: center top;
}
• background-size क्या होता है?
इसका उपयोग background image का size define करने के लिए होता है।
div {
background-size: cover;
}
• background-attachment क्या होता है?
यह control करता है कि background scroll होगा या fixed रहेगा।
div {
background-attachment: fixed;
}
• Background Shorthand क्या होता है?
Background shorthand property का इस्तेमाल करके आप सभी background related properties जैसे background-image, background-repeat, background-position, और background-size को एक ही लाइन में लिख सकते हैं।
div {
background: url("image.jpg") no-repeat center/cover;
}
4.CSS Background Image कैसे लगाएं? (Step-by-Step)
- अपनी HTML file में एक element बनाएं, जैसे
<div>
- CSS में उस element का selector लिखें
background-image
property के साथ image का path दें
Example:
<div class="bg-image"></div>
.bg-image {
width: 400px;
height: 300px;
background-image: url("nature.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
Explanation:
background-image
: यह property image set करती हैbackground-size: cover
: image पूरे element को cover करता हैbackground-repeat: no-repeat
: image को repeat होने से रोकता हैbackground-position: center
: image को center में रखता है
5. Common Mistakes in CSS Background Properties in Hindi
- गलत URL path देना, जिससे image load नहीं होती
- Image को compress ना करना, जिससे page load time बढ़ जाता है
background-size
सेट ना करना, जिससे image crop या गलत दिख सकती है- Contrast का ध्यान ना रखना, जिससे text background पर सही से दिख नहीं पाता
6. CSS Background Properties in Hindi vs Inline CSS: कौन सा बेहतर है?
Inline CSS:
<div style="background-color: red;"></div>
External CSS (recommended):
div {
background-color: red;
}
External CSS क्यों बेहतर है?
- यह फिर से इस्तेमाल (Reusable) किया जा सकता है, मतलब कई जगह एक साथ apply कर सकते हो।
- कोड को संभालना (Maintain) आसान होता है, क्योंकि बदलाव एक ही जगह से होते हैं।
- वेबसाइट की परफॉर्मेंस बेहतर होती है, क्योंकि CSS फाइल ब्राउज़र में कैश हो जाती है।
इसलिए हमेशा External CSS का इस्तेमाल करें ताकि आपका कोड साफ-सुथरा, व्यवस्थित और असरदार बने।
7. CSS Background Properties in Hindi – Practice Code उदाहरण (Copy-Paste Ready)
<!DOCTYPE html>
<html>
<head>
<style>
.bg-box {
width: 500px;
height: 300px;
background-image: url("https://www.w3schools.com/css/img_lights.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
border: 2px solid #000;
}
</style>
</head>
<body>
<div class="bg-box"></div>
</body>
</html>
Practice Code Output

8. CSS Background Properties in Hindi – FAQs (Frequently Asked Questions)
Q1: क्या मैं एक element में एक से ज्यादा background images लगा सकता हूँ?
उत्तर:
हाँ, आप background-image
में एक से ज्यादा images comma (,) से अलग करके लगा सकते हैं। जो पहली image होगी, वह सबसे ऊपर दिखेगी और बाकी नीचे।
element {
background-image: url(‘img1.png’), url(‘img2.png’);
background-position: top right, bottom left;
background-repeat: no-repeat, repeat;
}
ये तरीका W3Schools और MDN दोनों recommend करते हैं।
Q2: मोबाइल पर background image को responsive कैसे बनाएं?
उत्तर:background-size: cover;
से image बिना बिगड़े पूरे area को cover करती है। साथ में background-position: center;
रखें ताकि image बीच से crop हो।
अगर डेटा बचाना हो तो media queries से छोटे स्क्रीन के लिए हल्की image भेजें।
Q3: Background image को fixed कैसे रखें?
उत्तर:background-attachment: fixed;
use करें। इससे background image scroll नहीं होगी, केवल content scroll होगा।
element {
background: url(‘image.jpg’) center center / cover fixed no-repeat;
}
Q4: CSS sprites क्या हैं और कैसे use करें?
उत्तर:
CSS sprites एक single image होती है जिसमें कई छोटे graphics होते हैं। आप background-position
से उस image का एक हिस्सा दिखा सकते हैं। इससे multiple requests कम होती हैं और साइट fast चलती है।
.icon {
width: 50px;
height: 50px;
background: url(‘sprite.png’) -100px -50px no-repeat;
}
Ye technique file requests kam karta hai aur performance bhi improve hoti hai
Q5: Background image पर text साफ़ कैसे दिखाएं?
उत्तर:
Overlay technique से semi-transparent black layer लगाएं:
.hero {
position: relative;
background: url(‘hero.jpg’) center/cover no-repeat;
}
.hero::after {
content: ”;
position: absolute;
inset: 0;
background: rgba(0,0,0,0.4);
}
.hero-text {
position: relative;
color: white;
}
इससे text background के ऊपर आसानी से पढ़ा जा सकता है।image detailed ho.
Q6: Multiple background images के size कैसे control करें?
उत्तर:background-size
में comma से अलग अलग size दें:
element {
background-image: url(‘img1.png’), url(‘img2.png’);
background-size: 50px 50px, cover;
}
पहली image fixed size में और दूसरी पूरी जगह cover करेगी।
Q7: background-origin और background-clip क्या हैं?
उत्तर:
=> background-origin
तय करता है कि background image border, padding या content box से शुरू होगी।
=>background-clip
decide करता है कि background किस जगह तक दिखाई देगी, जैसे सिर्फ padding area या border तक।
Q8: Media queries से background image कैसे optimize करें?
उत्तर:
Responsive design के लिए अलग-अलग screen size पर अलग image दिखाएं:
body {
background: url(‘large.jpg’) center/cover no-repeat fixed;
}
@media(max-width: 767px) {
body {
background: url(‘small.jpg’) center/cover no-repeat;
}
}
इससे मोबाइल पर हल्की image और desktop पर हाई-क्वालिटी image दिखेगी।
इसे भी पढ़े –
- CSS Kya Hai in Hindi – Full Form, Types, Syntax और Example
- CSS Colors in Hindi – आसान हिंदी में पूरी जानकारी
- HTML Kya Hai? जानिए HTML का इतिहास, फीचर्स, टैग्स और फायदे
- HTML Form in Hindi – HTML Form क्या है और कैसे बनाएं
- JavaScript क्या है? जावास्क्रिप्ट के फायदे, उपयोग और सीखने का आसान तरीका – हिंदी में
- C Language Kya Hai? जानिए पूरी जानकारी हिंदी में
- Decision Making In C In Hindi – if, if-else, switch, break और goto स्टेटमेंट्स हिंदी में पूरी जानकारी
9. निष्कर्ष – आपने क्या सीखा?
दोस्तों, इस आर्टिकल में आपने CSS Background Properties in Hindi के सभी ज़रूरी और बेसिक कॉन्सेप्ट्स सीखे, जैसे कि:
- Background image कैसे लगाते हैं
- अलग-अलग background properties का इस्तेमाल
- Common mistakes और उनका सही समाधान
- Practice code के ज़रिए समझ
अगर आप CSS और HTML में expert बनना चाहते हैं, तो आप W3Schools CSS Background Guideभी पढ़ सकते हैं, जहां आपको और भी गहराई से जानकारी मिलेगी।
तो दोस्तों, अगर आपको यह आर्टिकल helpful लगा हो, तो इसे share, comment और अपने दोस्तों को recommend ज़रूर करें।
और हाँ—अगला आर्टिकल किस टॉपिक पर चाहिए? नीचे comment करके ज़रूर बताएं।
Written by: Aditya (Programming Sikho)