Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


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


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.


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.


    <h1>Window Splitter</h1>
    <p>A window splitter allows you to resize two parts of a webpage.</p>
    <section class="split">
        <aside id="toc">
                <h2 id="toc-title">Table of Contents</h2>
                    <li><a href="#start">Beginning</a></li>
                    <li><a href="#somewhere">Somewhere after the beginning</a></li>
                    <li><a href="#somewhere-else">Near the end</a></li>
                    <li><a href="#end">The end</a></li>
        <div role="separator"
            <span class="icon"></span>
            <h2>Enshrining Accessibility at Every Level</h2>

              When I started to learn HTML, I began with basic elements like <code>h1</code>, <code>p</code>, <code>div</code>, and <code>button</code>.
              I learned about semantics, creating sections with headings, and styling elements with CSS.
              Unconsciously, I was laying a foundation of knowledge on how to build accessible websites.
              When I began specialising in accessibility, this foundation made it much easier for me to grasp a lot of the web accessibility guidelines and rules—I already knew how to apply most of them.

                In 2014—eight years in as a front-end developer—I attended a talk by Heydon Pickering in which he mentioned accessibility.
                This is when I realised that semantics play an important role in accessibility.
                Before that talk, I had only written semantic HTML because that’s what I had learned to do.
                Looking back, I now realise that it shouldn’t have taken eight years before I learned about something as important as accessibility.

                In those eight years, I read a lot of articles about various web-related topics.
                I don’t remember accessibility being a prominent part of those articles.
                This is something that most certainly has improved since then—a lot of articles now explicitly mention accessibility. That’s so cool!

                We all play our part in the accessibility of content.
                So we should all have some accessibility knowledge that relates to our part of the puzzle.
                From media managers that make sure the videos have subtitles to developers that know when to use ARIA and when not to.
                This also includes the people in charge of projects, such as product owners, department heads, and CEOs.
                These are the people that actually have the power to make accessibility a project requirement and establish it as a goal that everyone has to work towards.

                It’s difficult to be the only person who fights for accessibility.
                And we shouldn’t have to fight.
                The reason that we have to is that our superiors either don’t know about accessibility or don’t care about it.
                If only one person fights for accessibility, it’ll remain a personal thing—it won’t become a part of a companies design process.
                On top of that, there are a lot of different aspects to accessibility, and you cannot expect one person to know all the ins and outs.
                One specialist per company isn’t enough to create an accessible product.

                Every member of the team should be fully behind accessibility.
                The same way that the team should be fully behind delivering a quality product.
                After all, accessibility is a big part of the quality of your website.

                Accessibility gets increasingly more attention.
                We need to make sure that people in the right places know about it.


                [role="separator"] {
    margin: 0;
    border: none;
    cursor: col-resize;
    background: white;
    background-image: linear-gradient(purple, purple);
    background-size: 2px 100%;
    background-repeat: no-repeat;
    background-position: center;

// Layout
.split {
    border: 2px solid purple;
    display: grid;
    grid-template-columns: 34% 1em auto;
    aside {
        overflow: hidden;
        padding-right: 1em;
    article {
        padding-left: 1em;

aside div {
    min-width: 13em;


                class WindowSplitter {
    constructor (element) {
        this.element = element = document.getElementById(element.getAttribute('aria-controls'))
        this.grid =
        this.step = 2
        this.value = {
            now: Number(element.getAttribute('aria-valuenow')),
            min: Number(element.getAttribute('aria-valuemin')),
            max: Number(element.getAttribute('aria-valuemax')),
            prev: Number(element.getAttribute('aria-valuenow'))
        this.dimensions = this.getDimensions()
    bindEvents () {
        this.element.addEventListener('keydown', event => this.keyEventHandler (event))
        // Ignore for now
        // this.element.addEventListener('drag', event => this.dragEventHandler (event))
        // this.element.addEventListener('dragstart', event => this.dragEventHandler (event))
        // this.element.addEventListener('mousedown', event => this.dragEventHandler(event))
        // this.element.addEventListener('touchstart', event => this.dragEventHandler(event))
    getDimensions () {
        return {
            top: this.grid.getBoundingClientRect().top,
            right: this.grid.getBoundingClientRect().right,
            bottom: this.grid.getBoundingClientRect().bottom,
            left: this.grid.getBoundingClientRect().left,
            width: this.grid.getBoundingClientRect().width

    getMousePosition (event) {
        return event.clientX
    keyEventHandler (event) {
        const key = event.key
        switch (key) {
            case "ArrowLeft":
            case "ArrowUp":
                this.setSize( - this.step)
            case "ArrowRight":
            case "ArrowDown":
                this.setSize( + this.step)
            case "Enter":
            case "Home":
            case "End":
                throw new Error('Something went wrong with the keyboard support')
    dragEventHandler (event) {
        // Ignore this for now
        const dragStartOffset = this.getMousePosition(event)
        console.log('dragStartOffset', dragStartOffset, this.dimensions.width)
    collapse () {
        if ( !== 0) {
        } else {
    setSize (size) {
        if (size < this.value.min) {
            size = this.value.min
        } else if (size > this.value.max) {
            size = this.value.max
        this.value.prev = = size
        this.element.setAttribute('aria-valuenow', size) = size + '% 1em auto'

    .forEach(element => new WindowSplitter(element))