Skip to content

docs(css): add scroll-padding example for fixed header#42548

Open
lucifer13598 wants to merge 7 commits into
mdn:mainfrom
lucifer13598:main
Open

docs(css): add scroll-padding example for fixed header#42548
lucifer13598 wants to merge 7 commits into
mdn:mainfrom
lucifer13598:main

Conversation

@lucifer13598
Copy link
Copy Markdown

Description

Added a new example to the scroll-padding documentation demonstrating how it prevents content from being hidden behind a fixed-position header.

Motivation

The existing documentation explained the concept but did not include a practical example. This change helps readers clearly understand a common real-world use case when using fragment links with fixed headers.

Additional details

No additional references required.

Related issues and pull requests

Fixes #42183

@lucifer13598 lucifer13598 requested a review from a team as a code owner December 27, 2025 09:28
@lucifer13598 lucifer13598 requested review from chrisdavidmills and removed request for a team December 27, 2025 09:28
@github-actions github-actions Bot added Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed labels Dec 27, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 4, 2026

Preview URLs

Flaws (11)

URL: /en-US/docs/Web/CSS/Reference/Properties/scroll-padding
Title: scroll-padding
Flaw count: 11

  • broken_links:
    • Link /en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax#brackets is a redirect
    • Link /en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax#single_bar is a redirect
    • Link /en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax#brackets is a redirect
    • Link /en-US/docs/Web/CSS/CSS_values_and_units/Value_definition_syntax#curly_braces is a redirect
    • Link /en-US/docs/Web/CSS/length is a redirect
    • and 2 more flaws omitted
  • macros:
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_cascade/Value_processing which is a redirect
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_cascade/Inheritance which is a redirect
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_cascade/Value_processing which is a redirect
    • Macro cssinfo produces link /en-US/docs/Web/CSS/CSS_animated_properties which is a redirect

(comment last updated: 2026-01-04 17:41:51)

Copy link
Copy Markdown
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @lucifer13598, and thank you for your contribution to MDN.

I had a few comments for you; let me know what you think of them.

Comment thread files/en-us/web/css/reference/properties/scroll-padding/index.md
Comment thread files/en-us/web/css/reference/properties/scroll-padding/index.md Outdated
Comment thread files/en-us/web/css/reference/properties/scroll-padding/index.md Outdated
A common use case for `scroll-padding` is when a page includes a fixed-position header.
Without `scroll-padding`, content linked via fragment identifiers can be hidden beneath the header.

```css
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it stands, this doesn't really demonstrate the use case very clearly. Can you expand the example to show more complete code and a live example perhaps? It doesn't have to be as elaborate as this example, but this is the kind of pattern you should ideally follow: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/scroll-target-group#basic_scroll-target-group_usage.

@estelle estelle requested a review from a team as a code owner June 4, 2026 13:14
@estelle estelle requested review from pepelsbey and removed request for a team June 4, 2026 13:14
estelle and others added 3 commits June 4, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scroll-padding demo could better highlight how useful the property is

4 participants