websafe.js: // Generates and array of strings containing all 216 web-safe colour codes function getWebsafeColours() { var colours = []; var hex; var parts = ["00", "33", "66", "99", "cc", "ff"]; for (var i=0; i < 216; i++) { colours.push("#" + parts[Math.floor(i/36)] + parts[Math.floor((i/6)%6)] + parts[i % 6]); } return colours; } // Populates the div called "palettes" in the webpage using the colours passed in function generatePalettes(colours) { var palettes = document.getElementById("palettes"); for (var i=0;i "; palettes.appendChild(palette); } } // Populate the palette once the page is done loading window.onload= function() { generatePalettes(getWebsafeColours()); } websafe.html: Untitled Document

Web-Safe Colour Palette

All 216 colours

Colour Code: