← Back to CSS Course | Chapter 4: Text & Fonts | Lesson 9 of 10

CSS Lists

आपने web पर जो भी bullet point और numbered step देखा है वह एक HTML list से आता है जिसे CSS से style किया गया है। Default रूप से, browsers अपने आप अपने bullets या numbers जोड़ते हैं, लेकिन CSS आपको उस styling को पूरी तरह बदलने, customize करने, या हटाने का पूरा control देता है। list-style-type marker shape control करता है (एक bullet, एक number, letters, या बिल्कुल कुछ नहीं), list-style-image उस marker को एक custom picture से बदल देता है, और list-style-position control करता है कि marker content flow के अंदर बैठता है या बाहर। एक shorthand list-style property भी है, और किसी list को layout के लिए इस्तेमाल करते समय उसकी default styling को पूरी तरह हटाना बेहद common है, जैसे कोई navigation menu। Lists cookiescursor.com जैसी असली site पर लगातार दिखती हैं, simple feature bullet points से लेकर list items से बने पूरी तरह custom-styled navigation bars तक।
Syntax
css
selector {
  list-style-type: disc | circle | square | decimal | none;
  list-style-position: inside | outside;
}

list-style-type

list-style-type किसी list के markers की shape set करता है, जैसे disc (एक filled circle), decimal (numbers), या none (बिल्कुल कोई marker नहीं)। इसे none set करना list markup से custom navigation menus बनाते समय एक common पहला step है।

Note:
  • Unordered lists default रूप से disc पर और ordered lists decimal पर होती हैं, लेकिन आप mix और match कर सकते हैं, जैसे किसी sub-list के लिए letters इस्तेमाल करना।
  • Accepted values:
  • disc | circle | square — ul के लिए bullet styles
  • decimal | decimal-leading-zero — numbers
  • lower-alpha | upper-alpha | lower-roman | upper-roman — letters और Roman numerals
  • lower-latin | upper-latin | lower-greek — दूसरे alphabets
  • none — marker हटा देता है
  • inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
Warning: list-style-type: none set करना सिर्फ visible marker हटाता है, list items खुद अपनी default left padding रख सकते हैं।

उदाहरण: list-style-type

css
<style>
ul {
  list-style-type: square;
}
ol {
  list-style-type: decimal;
}
</style>
<ul><li>Item</li></ul>
<ol><li>Item</li></ol>

list-style-image

list-style-image किसी list के marker को url() से reference किए गए एक custom image से बदल देता है, जो standard bullet shapes से आगे lists को एक distinctive branded look देता है। अगर referenced image load न हो पाए, तो ज़्यादातर browsers चुपचाप default bullet के बजाय बिल्कुल कोई marker न होने पर fall back हो जाते हैं।

Note:
  • Custom marker images को छोटा और simple रखें, एक बहुत बड़ी या detailed marker image किसी list की vertical rhythm बिगाड़ सकती है।
  • Accepted values:
  • url("...") — marker के रूप में एक image
  • none — कोई image नहीं (initial value)
  • एक gradient — marker image के रूप में भी valid
  • list-style-type — image fail होने पर fallback के तौर पर इस्तेमाल होता है
  • inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
Warning: हमेशा list-style-image को list-style-type fallback के साथ जोड़ें, इस स्थिति में कि custom image load न हो पाए।

उदाहरण: list-style-image

css
<style>
li {
  list-style-image: url('https://placehold.co/16x16');
}
</style>
<ul><li>Custom marker image</li></ul>

list-style-position

list-style-position control करता है कि कोई marker list item के content box के बाहर बैठता है (default) या उसके अंदर, जो बदल देता है कि किसी लंबे list item की wrapped lines marker के साथ कैसे align होती हैं।

Note:
  • list-style-position: inside इस्तेमाल करें जब आप चाहें कि किसी list item की wrapped lines ऊपर के text के बजाय marker के साथ flush align हों।
  • Accepted values:
  • outside — marker box के बाहर बैठता है (initial value)
  • inside — marker content flow का हिस्सा है
  • inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
Warning: inside positioning पर switch करना list items को outside positioning से visually अलग दिखा सकता है, खासतौर पर लंबे, multi-line content के साथ।

उदाहरण: list-style-position

css
<style>
.outside { list-style-position: outside; }
.inside { list-style-position: inside; }
</style>
<ul class="outside"><li>Marker sits outside the content box</li></ul>
<ul class="inside"><li>Marker sits inside the content box</li></ul>

Shorthand list-style Property

list-style shorthand type, position, और image को एक declaration में combine करता है, किसी भी order में, दूसरी CSS shorthand properties की तरह ही। दूसरी CSS shorthands की तरह ही, जिस भी value को आप छोड़ते हैं वह पिछली value पर बने रहने के बजाय अपनी default पर reset हो जाती है।

Note:
  • एक बार जब आप individual properties में सहज हो जाएँ तो किसी list की marker behavior को एक line में पूरी तरह define करने का shorthand एक तेज़ तरीका है।
  • Accepted values:
  • type — disc, circle, square, decimal, none और दूसरे
  • position — inside या outside
  • image — url() या none
  • values किसी भी order में हो सकती हैं
  • inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
Warning: shorthand में छोड़ा गया कोई भी हिस्सा अपनी default पर reset हो जाता है, जो आपकी CSS में कहीं और defined किसी setting को चुपचाप हटा सकता है।

उदाहरण: Shorthand list-style Property

css
<style>
ul {
  list-style: square inside url('https://placehold.co/16x16');
}
</style>
<ul><li>Type, position, and image in one line</li></ul>

Navigation Menus के रूप में Lists

एक semantic, unordered list किसी navigation menu के लिए standard, accessible foundation है, जिसे list-style: none और flex layout से style किया जाता है ताकि items vertically stacked होने के बजाय horizontally arrange हों।

Note: bullets हटाने के बाद भी navigation के लिए एक असली ul/li structure इस्तेमाल करते रहें, screen readers अभी भी इसे items की एक proper list के रूप में announce करते हैं।
Warning: किसी navigation menu के लिए एक semantic list को plain divs से replace करना वह structural meaning हटा देता है जिस पर assistive technology निर्भर करती है।

उदाहरण: Lists as Navigation Menus

css
<style>
ul {
  list-style: none;
  display: flex;
  gap: 10px;
}
li {
  background: lightblue;
  padding: 6px 10px;
}
</style>
<ul>
  <li><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
</ul>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह भूल जाना कि default list styles हटाना (list-style: none) कुछ browsers द्वारा लागू किए गए left indent को भी हटा देता है, जिसके लिए padding भी reset करनी पड़ती है।
  2. list-style-image को बिना किसी fallback list-style-type के इस्तेमाल करना, इस स्थिति में कि custom image load न हो पाए।
  3. किसी navigation menu को plain divs से style करना semantic list के बजाय, lists द्वारा दी गई built-in structure को missing करते हुए।
चैप्टर सारांश
  • list-style-type list items के लिए marker style (disc, decimal, none, और दूसरे) set करता है।
  • list-style-image default marker को एक custom image से बदल देता है, और list-style-position उसकी placement control करता है।
  • list-style: none आमतौर पर तब इस्तेमाल होता है जब default bullets हटाने हों क्योंकि किसी list को layout के लिए इस्तेमाल किया जा रहा है, जैसे navigation।
ब्राउज़र सपोर्ट

यहाँ बताई गई सभी standard CSS list-style properties हर modern browser में supported हैं।

🔒

Chapter Quiz — Complete all 10 topics to unlock

0/10 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.