Pen Settings



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


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.


                <div id="mainContainer">
        <div id="tooltipContainer"></div>
        <div class="sectionContainer">
            <p>Try <i>highlighting</i> some text below</p>
            <div id="textContainer">
                <p id="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus congue condimentum ante
                    laoreet tempus.
                    Phasellus semper vitae turpis et luctus. Quisque viverra ligula quis iaculis luctus. Vivamus et nibh
                    justo bibendum placerat. Nullam auctor fringilla risus, a eleifend purus pharetra et. Cras varius
                    non felis egestas, quis mollis sem ultricies. Vestibulum congue mattis sem. Suspendisse ut dui in
                    faucibus feugiat id suscipit risus. Donec lobortis ligula ac dictum tincidunt. Quisque lacus metus,
                    porta eu lobortis ultricies, aliquet ac mi. Maecenas lobortis mollis diam, sagittis pulvinar urna
                    a. Phasellus quis nibh felis. Cras porta pharetra interdum. Nam sodales purus vitae malesuada
    <script src="[email protected]"></script>
    <script src="[email protected]"></script>
    <script src="index.js"></script>


                body {
    display: grid;
  height: 100vh;
    place-items: center;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;

#mainContainer {
    width: 75vw;

div {
    display: grid;
    place-items: center;

#textContainer {
    padding: 24px;
    border-radius: 4px;
    display: grid;
    place-items: center;
    background-color: #abcbca;

#textContainer>p {
    color: white;
    letter-spacing: 2px;
    font-size: 16px;

p::selection {
    background-color: gainsboro;
    color: black;

#tooltipContainer {
    position: absolute;


                const [instance] = tippy('#tooltipContainer', {
    content: 'tooltip',
    sticky: true

const tooltipContainer = document.getElementById("tooltipContainer");
document.getElementById("textContainer").addEventListener("mouseup", () => {
    let selection = document.getSelection();
    if (!selection.isCollapsed) {
        const { left, top, width, height } = selection.getRangeAt(0).getBoundingClientRect()
    = `${left}px` = `${top}px` = `${width}px` = `${height}px`

        const numLines = selection.toString().length;
        instance.setContent(`Great Job! You selected ${numLines} charcters!`);

document.addEventListener('mousedown', (event) => {
    console.log("hiding") = `${0}px` = `${0}px`