Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Anchor Links</h1>

<p>Check this <a href="https://github.com/valeriangalliat/markdown-it-anchor/issues/82">discussion</a> on GitHub.</p>

<div>
  <p>This solution uses a link inside a heading (like on <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#deprecated_attributes">MDN</a>) but with the addition of a "visual cue" ("#") meant to activate the link (via pointing device) while <em>allowing users to easily select the text</em> inside the headings.</p>

  <p><b>Notes</b>:</p>
<ul>
  <li>I am applying the rule via <code>@media (hover:hover)</code> so touch devices should get simple links but it may be better to use <code>@media (any-pointer:coarse)</code></li>
  <li>On touch devices, the heading will appear as links (same styling) but if your links are underline then you should add <code>text-decoration</code> to them.</li>
  <li>I am styling the text with an underline on mouseover. I think it may give a hint to the users about what clicking on the "#" may do but I may be wrong, that could be more confusing to some.</li>
  <li>I am adding extra padding to the "#" to make it a bigger target but another option could be to scale it on mouseover, with some kind of pulse animation may be (?)...</li>
  </ul>
  </div>

<h2 id="lorem">
  <a href="#lorem">Lorem</a>
</h2>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<h2 id="ipsum">
  <a href="#ipsum">Ipsum</a>
</h2>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<h2 id="dolor">
  <a href="#dolor">Dolor</a>
</h2>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<h2 id="sit-amet">
  <a href="#sit-amet">Sit Amet</a>
</h2>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
              
            
!

CSS

              
                h2 a:hover {
  text-decoration: underline;
}
@media (hover: hover) {
  h2 {
    margin-left: -1em;
    padding-left: 1em;
  }
  h2 a {
    text-decoration: none;
    pointer-events: none;
    color: #0a0a0a !important;
  }
  h2 a::before {
    content: "#";
    float: left;
    padding: 0 .15em; /* to make the "#" a bigger target */
    margin-left: -1em;
    pointer-events: auto;
    color: #1779ba;
    display: none;
  }
  h2:hover a::before {
    display: block;
  }
}
/******/

body {
  padding: 1em 3em 50em;
}
code {
  white-space: nowrap;
}
div {
  font-size: 1.2em;
}

              
            
!

JS

              
                
              
            
!
999px

Console