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.


                <!DOCTYPE html>
<html lang="en">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Detect User Browser and OS</title>
    <!-- Google Font -->
    <!-- Stylesheet -->
<style media="screen">
* {
padding: 0;
margin: 0;
box-sizing: border-box;
body {
background-color: #328cf3;
#container {
position: absolute;
background-color: #ffffff;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
width: 90vw;
max-width: 500px;
padding: 20px;
border-radius: 5px;
font-family: "Poppins", sans-serif;
font-size: 5vmin;
color: #051a32;
font-weight: 600;
line-height: 1.8em;
text-align: center;
box-shadow: 0 20px 50px rgba(5, 26, 50, 0.18);
#container span {
font-weight: 700;
color: #9d1df3;

    <div id="container">
      You are using <span id="browser-details"></span><br />

    <!-- Script -->
let browserDetailsRef = document.getElementById("browser-details");
var browserList = [
{ name: "Firefox", value: "Firefox" },
{ name: "Opera", value: "OPR" },
{ name: "Edge", value: "Edg" },
{ name: "Chrome", value: "Chrome" },
{ name: "Safari", value: "Safari" },

let broswerChecker = () => {
//Useragent contains browser details and OS  details but we need to separate them
let userDetails = navigator.userAgent;
for (let i in browserList) {
  //check if the string contains any value from the array
  if (userDetails.includes(browserList[i].value)) {
    //extract browser name and version from the string
    browserDetailsRef.innerHTML = browserList[i].name || "Unknown Browser";

window.onload = broswerChecker();