<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
</head>

<body>

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <link rel="stylesheet" href="style.css">

        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Color flipper</title>
    </head>

    <body>
        <div class="container">
            <h2 class="the-color">Color:
                <br>
                <span class="color">
                    #f3f3f3
                </span>
            </h2>
            <button class="btn btn-main" id="btn">Click me</button>

        </div>

        <script src="script.js"></script>
    </body>

</html>
*,*::before,*::after{
    box-sizing: border-box;
}
::selection{
   background-color:aqua;
   color:#1c1d25;
}
body{
    background-color: #ffffff;
}

.container{
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
    position: absolute;
    top:40%;
    left:50%;
    transform:translate(-50%,-50%);

}
.the-color{
    background-color: #1c1d25;
    color:#f3f3f3;
    letter-spacing: 5px;
    padding:1em 3em;
    width: 12em;
    border-radius: .5em;
    text-align: center;
    line-height: 1.6;
}
.btn-main{
    position: absolute;
    top:150%;
    left:50%;
    transform:translate(-50%,-150%);

    background-color: transparent;
    border: 3px solid #1c1d25;
    border-radius: .4em;
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
    font-size: 1.3em;
    letter-spacing: 2px;
    padding:.5em 1em;
    margin-top:1em;
    white-space: nowrap;
    text-shadow: 0 0 5px 5px white;
}
const btn = document.getElementById("btn");
const color = document.querySelector(".color");

btn.addEventListener("click", function () {
    let hexColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
    color.textContent = hexColor;
    document.body.style.backgroundColor = hexColor;
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.