Skip to content
Advertisement

Add a space on top of a #page HTML link

When I have a link that loads a section within the same page, the link will make the section clicked on load at the top of the browser window, I need to somehow add a space/gap of like 100px on top of all these sections that are linked like this.

Any ideas on how to do this?

The link to section
<a href="#page">Page</a>


The section
<a id="page"></a>

Advertisement

Answer

In your css just set the padding-top to 100px (you’ll need some form of CSS selector to target only the ‘correct’ links):

a.someCssClassOrSelector {
  padding-top: 100px
}
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement