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.


Auto Save

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="latest-news" class="marquee">
    <span style="white-space:nowrap;">
        <a href="#">Explore the hidden wonders of nature</a>
        <a href="#">Ignite your passion for creativity</a>
        <a href="#">Embrace the journey, not just the destination</a>
        <a href="#">Discover the magic in everyday moments</a>
        <a href="#">Chase your dreams with fearless enthusiasm</a>

<p><a href="">See more marquee scripts here.</a></p>


                .marquee {
    position: relative;
    overflow: hidden;
    text-align: center;
    margin: 0 auto;
    width: 100%;
    height: 30px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    font-size: 24px;



                function initializeMarquee() {

window.onload = initializeMarquee;

function getObjectWidth(obj) {
    if (obj.offsetWidth) return obj.offsetWidth;
    if (obj.clip) return obj.clip.width;
    return 0;

const marqueeContainers = [];

function createMarqueeContainer(id) {
    const container = document.getElementById(id);
    const itemWidth = getObjectWidth(container.getElementsByTagName("span")[0]) + 5;
    const fullWidth = getObjectWidth(container);
    const textContent = container.getElementsByTagName("span")[0].innerHTML;
    container.innerHTML = "";
    const height =;

    container.onmouseout = () => rotateMarquee(marqueeContainers);
    container.onmouseover = () => cancelAnimationFrame(marqueeContainers[0].animationID);

    container.items = [];
    const maxItems = Math.ceil(fullWidth / itemWidth) + 1;

    for (let i = 0; i < maxItems; i++) {
        container.items[i] = document.createElement("div");
        container.items[i].innerHTML = textContent;
        container.items[i].style.position = "absolute";
        container.items[i].style.left = itemWidth * i + "px";
        container.items[i].style.width = itemWidth + "px";
        container.items[i].style.height = height;


function rotateMarquee(containers) {
    if (!containers) return;

    for (let j = containers.length - 1; j > -1; j--) {
        const maxItems = containers[j].items.length;

        for (let i = 0; i < maxItems; i++) {
            const itemStyle = containers[j].items[i].style;
            itemStyle.left = parseInt(itemStyle.left, 10) - 1 + "px";

        const firstItemStyle = containers[j].items[0].style;

        if (parseInt(firstItemStyle.left, 10) + parseInt(firstItemStyle.width, 10) < 0) {
            const shiftedItem = containers[j].items.shift();
   = parseInt( + parseInt( * maxItems + "px";

    containers[0].animationID = requestAnimationFrame(() => rotateMarquee(containers));