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.


                <!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>RGBizer - Your Color Code Convertor</title>
        <div class="main-child">
            <h1>Color Hex to RGB convertor</h1>
            Enter the hexadecimal code of your favarite color in the box below to get rgb() equivalente
                <label for="hex-code">#</label>
                <input type="text" placeholder="Enter hex code without #" name="hex-code" id="hex-code">
                <input type="submit" value="Run">
                <p>RGB color is <span id="rgb"></span></p>
        <div id="preview" class="main-child">
            <p>Color preview</p>



                body {
            box-sizing: border-box;
            margin: 0;

        main {
            display: flex;
            /*height: 46em;  */          
            align-items: center;
            justify-content: center;

        .main-child {
            width: 50%;
            height: 100%;
           text-align: center;

        #rgb {
            font-weight: bold;


                const formElt = document.querySelector('form');
const hexColor = document.querySelector('input[type="text"]').value ;
const rgbDOM = document.querySelector('#rgb');
const previeWDOM = document.querySelector('#preview');

const hex2decTable = {
  'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15

function colorCode(array) {
  const code = array.reduce((acc, cur) => {
    if ( isNaN(acc) ) acc = hex2decTable[acc];
    if ( isNaN(cur) ) cur = hex2decTable[cur];

    return parseInt(acc) * 16 + parseInt(cur)

  return code;

formElt.addEventListener('submit', e => {


  const hexColorArr = hexColor.split('');

  const initRedColorArr = hexColorArr.slice(0,2);
  const initGreenColorArr = hexColorArr.slice(2,4);
  const initBlueColorArr = hexColorArr.slice(4);

  const redCode = colorCode(initRedColorArr);
  const greenCode = colorCode(initGreenColorArr);
  const blueCode = colorCode(initBlueColorArr);

  rgbDOM.innerHTML = 'rgb('+ redCode + ',' + greenCode + ',' + blueCode + ')'; = '#' + hexColor; = '#' + hexColor;