CSS • Chapter 29 • Foundations to Production
Lists and Counters
Every topic includes a CSS/HTML coding example, ten focused teaching examples, code explanation, expected result, practice, and responsive/translated-layout checks.
29.1 list-style
list-style is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For list-style in Chapter 29, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for list-style, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 29, topic 1.
Concept in plain language
list-style is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal data table for list-style. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 29, topic 1, example 1.
Example 2: Change one value
Change one important CSS value in the media player example for list-style. Predict the visual difference before reloading the page. Chapter 29, topic 1, example 2.
Example 3: Narrow-screen test
Test list-style in the notification at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 29, topic 1, example 3.
Example 4: Translated-text test
Translate the language selector into a language with longer labels while using list-style. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 29, topic 1, example 4.
Example 5: Arabic/Persian test
Switch the course card to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 29, topic 1, example 5.
Example 6: Accessibility test
Check list-style in the navigation bar with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 29, topic 1, example 6.
Example 7: Cascade test
Add a competing rule to the article and determine why the declaration for list-style wins or loses using the browser's Styles and Computed panels. Chapter 29, topic 1, example 7.
Example 8: Content-stress test
Fill the profile panel with very long words, URLs, translated text, images, and nested controls. Adjust list-style without hiding meaningful content. Chapter 29, topic 1, example 8.
Example 9: Refactoring test
Rewrite the search form so list-style uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 29, topic 1, example 9.
Example 10: Production review
Review list-style in the dashboard for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 29, topic 1, example 10.
CSS/HTML coding example
<!-- HTML -->
<h2>Balanced heading</h2>
<style>
:is(h1,h2,h3) { text-wrap: balance; }
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate list-style.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- :is() groups selector alternatives without repeating the rest of the selector.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates list-style without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 29, topic 1.
Practice exercise
Build a fresh example for list-style from Chapter 29. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
29.2 list-style-position
list-style-position is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For list-style-position in Chapter 29, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for list-style-position, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 29, topic 2.
Concept in plain language
list-style-position is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal language selector for list-style-position. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 29, topic 2, example 1.
Example 2: Change one value
Change one important CSS value in the course card example for list-style-position. Predict the visual difference before reloading the page. Chapter 29, topic 2, example 2.
Example 3: Narrow-screen test
Test list-style-position in the navigation bar at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 29, topic 2, example 3.
Example 4: Translated-text test
Translate the article into a language with longer labels while using list-style-position. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 29, topic 2, example 4.
Example 5: Arabic/Persian test
Switch the profile panel to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 29, topic 2, example 5.
Example 6: Accessibility test
Check list-style-position in the search form with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 29, topic 2, example 6.
Example 7: Cascade test
Add a competing rule to the dashboard and determine why the declaration for list-style-position wins or loses using the browser's Styles and Computed panels. Chapter 29, topic 2, example 7.
Example 8: Content-stress test
Fill the photo gallery with very long words, URLs, translated text, images, and nested controls. Adjust list-style-position without hiding meaningful content. Chapter 29, topic 2, example 8.
Example 9: Refactoring test
Rewrite the pricing table so list-style-position uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 29, topic 2, example 9.
Example 10: Production review
Review list-style-position in the lesson sidebar for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 29, topic 2, example 10.
CSS/HTML coding example
<!-- HTML -->
<h2>Balanced heading</h2>
<style>
:is(h1,h2,h3) { text-wrap: balance; }
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate list-style-position.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- :is() groups selector alternatives without repeating the rest of the selector.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates list-style-position without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 29, topic 2.
Practice exercise
Build a fresh example for list-style-position from Chapter 29. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
29.3 ::marker
::marker is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For ::marker in Chapter 29, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for ::marker, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 29, topic 3.
Concept in plain language
::marker is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal article for ::marker. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 29, topic 3, example 1.
Example 2: Change one value
Change one important CSS value in the profile panel example for ::marker. Predict the visual difference before reloading the page. Chapter 29, topic 3, example 2.
Example 3: Narrow-screen test
Test ::marker in the search form at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 29, topic 3, example 3.
Example 4: Translated-text test
Translate the dashboard into a language with longer labels while using ::marker. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 29, topic 3, example 4.
Example 5: Arabic/Persian test
Switch the photo gallery to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 29, topic 3, example 5.
Example 6: Accessibility test
Check ::marker in the pricing table with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 29, topic 3, example 6.
Example 7: Cascade test
Add a competing rule to the lesson sidebar and determine why the declaration for ::marker wins or loses using the browser's Styles and Computed panels. Chapter 29, topic 3, example 7.
Example 8: Content-stress test
Fill the contact form with very long words, URLs, translated text, images, and nested controls. Adjust ::marker without hiding meaningful content. Chapter 29, topic 3, example 8.
Example 9: Refactoring test
Rewrite the button group so ::marker uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 29, topic 3, example 9.
Example 10: Production review
Review ::marker in the data table for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 29, topic 3, example 10.
CSS/HTML coding example
<!-- HTML -->
<ul><li>One</li><li>Two</li></ul>
<style>
li::marker { color: #7c3aed; font-weight: 800; }
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate ::marker.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- ::marker styles list item markers.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates ::marker without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 29, topic 3.
Practice exercise
Build a fresh example for ::marker from Chapter 29. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
29.4 counter-reset
counter-reset is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For counter-reset in Chapter 29, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for counter-reset, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 29, topic 4.
Concept in plain language
counter-reset is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal dashboard for counter-reset. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 29, topic 4, example 1.
Example 2: Change one value
Change one important CSS value in the photo gallery example for counter-reset. Predict the visual difference before reloading the page. Chapter 29, topic 4, example 2.
Example 3: Narrow-screen test
Test counter-reset in the pricing table at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 29, topic 4, example 3.
Example 4: Translated-text test
Translate the lesson sidebar into a language with longer labels while using counter-reset. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 29, topic 4, example 4.
Example 5: Arabic/Persian test
Switch the contact form to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 29, topic 4, example 5.
Example 6: Accessibility test
Check counter-reset in the button group with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 29, topic 4, example 6.
Example 7: Cascade test
Add a competing rule to the data table and determine why the declaration for counter-reset wins or loses using the browser's Styles and Computed panels. Chapter 29, topic 4, example 7.
Example 8: Content-stress test
Fill the media player with very long words, URLs, translated text, images, and nested controls. Adjust counter-reset without hiding meaningful content. Chapter 29, topic 4, example 8.
Example 9: Refactoring test
Rewrite the notification so counter-reset uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 29, topic 4, example 9.
Example 10: Production review
Review counter-reset in the language selector for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 29, topic 4, example 10.
CSS/HTML coding example
<!-- HTML -->
<ol class="steps"><li>Structure</li><li>Layout</li><li>Responsive design</li></ol>
<style>
.steps{counter-reset:item}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate counter-reset.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The list rule demonstrates counter-reset.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates counter-reset without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 29, topic 4.
Practice exercise
Build a fresh example for counter-reset from Chapter 29. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
29.5 counter-increment
counter-increment is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For counter-increment in Chapter 29, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for counter-increment, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 29, topic 5.
Concept in plain language
counter-increment is part of the CSS system covered in Chapter 29. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal lesson sidebar for counter-increment. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 29, topic 5, example 1.
Example 2: Change one value
Change one important CSS value in the contact form example for counter-increment. Predict the visual difference before reloading the page. Chapter 29, topic 5, example 2.
Example 3: Narrow-screen test
Test counter-increment in the button group at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 29, topic 5, example 3.
Example 4: Translated-text test
Translate the data table into a language with longer labels while using counter-increment. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 29, topic 5, example 4.
Example 5: Arabic/Persian test
Switch the media player to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 29, topic 5, example 5.
Example 6: Accessibility test
Check counter-increment in the notification with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 29, topic 5, example 6.
Example 7: Cascade test
Add a competing rule to the language selector and determine why the declaration for counter-increment wins or loses using the browser's Styles and Computed panels. Chapter 29, topic 5, example 7.
Example 8: Content-stress test
Fill the course card with very long words, URLs, translated text, images, and nested controls. Adjust counter-increment without hiding meaningful content. Chapter 29, topic 5, example 8.
Example 9: Refactoring test
Rewrite the navigation bar so counter-increment uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 29, topic 5, example 9.
Example 10: Production review
Review counter-increment in the article for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 29, topic 5, example 10.
CSS/HTML coding example
<!-- HTML -->
<ol class="steps"><li>Structure</li><li>Layout</li><li>Responsive design</li></ol>
<style>
.steps{counter-increment:item}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate counter-increment.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The list rule demonstrates counter-increment.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates counter-increment without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 29, topic 5.
Practice exercise
Build a fresh example for counter-increment from Chapter 29. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
Chapter 29 review — 10 questions and answers
1. What should you inspect first when list-style does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for list-style. Then reduce the example until the winning declaration is clear.
2. How should list-style be checked before publishing?
Answer: Test list-style on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
3. What should you inspect first when list-style-position does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for list-style-position. Then reduce the example until the winning declaration is clear.
4. How should list-style-position be checked before publishing?
Answer: Test list-style-position on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
5. What should you inspect first when ::marker does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for ::marker. Then reduce the example until the winning declaration is clear.
6. How should ::marker be checked before publishing?
Answer: Test ::marker on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
7. What should you inspect first when counter-reset does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for counter-reset. Then reduce the example until the winning declaration is clear.
8. How should counter-reset be checked before publishing?
Answer: Test counter-reset on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
9. What should you inspect first when counter-increment does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for counter-increment. Then reduce the example until the winning declaration is clear.
10. How should counter-increment be checked before publishing?
Answer: Test counter-increment on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.