HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
HSL color values are supported in IE9+, Firefox, Chrome, Safari, and in Opera 10+
HSL color values are supported in IE9+, Firefox, Chrome, Safari, and in Opera 10+.
HSL stands for hue, saturation, and lightness.
HSL color values are specified with: hsl(hue, saturation,
lightness)
.
Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, 240 is blue.
Saturation is a percentage value; 0% means a shade of gray and 100% is the full color.
Lightness is also a percentage; 0% is black, 100% is white.
function submitOnEnter(e) { keyboardKey = e.which || e.keyCode; if (keyboardKey == 13) { setFullColor(); } } function clickHue(hue) { var h = document.getElementById("hue01"); h.value = hue; setColor(h); } function clickSat(sat) { var s = document.getElementById("sat01"); s.value = sat; setColor(s); } function clickLig(lig) { var l = document.getElementById("lig01"); l.value = lig; setColor(l); } function drawHueTable(hue) { var x, i, n; x = "
" + n + " | ";
}
x += "
"; } x += " |
" + i + " | ";
}
x += "
"; } x += " |
" + i + " | ";
}
x += "
"; } x += " |
HSL color values are supported in all major browsers.
<style>
div {
background-color: hsl(180, 50%, 50%);
color: hsl(0, 0%, 100%);
}
</style>
var btnclck = false; if (window.addEventListener) { window.addEventListener("mousedown", function () {btnclck = true; }); } else if (window.attachEvent) { window.attachEvent("onmousedown", function () {btnclck = true; }); } if (window.addEventListener) { window.addEventListener("mouseup", function () {btnclck = false; }); } else if (window.attachEvent) { window.attachEvent("onmouseup", function () {btnclck = false; }); } function tooltip(e, n) { var x; if (btnclck) { if (e == 0) { x = document.getElementById("hue01"); } if (e == 1) { x = document.getElementById("sat01"); } if (e == 2) { x = document.getElementById("lig01"); } x.value = n; setColor(x); } } function setColor(elmnt) { var ele, col, h, s, l, rgb; h = document.getElementById("hue01"); s = document.getElementById("sat01"); l = document.getElementById("lig01"); elmnt.value = Number(elmnt.value); if (parseInt(elmnt.value) < 0) {elmnt.value = "0";} if (elmnt.id == "hue01") { if (parseInt(elmnt.value) > 360) {elmnt.value = "360";} } else { if (parseInt(elmnt.value) > 100) {elmnt.value = "100";} } rgb = w3color("hsl(" + h.value + ", " + s.value + "%, " + l.value + "%)"); document.getElementById("result01").style.backgroundColor = rgb.toHslString(); document.getElementById("hsl01").value = rgb.toHslString(); document.getElementById("rgb01").innerHTML = rgb.toRgbString(); document.getElementById("hex01").innerHTML = rgb.toHexString(); for (i = 0; i <= 360; i++) { document.getElementById("huepointer" + i).style.display = "none"; } drawSatTable(h.value); drawLigTable(h.value); for (i = 0; i <= 100; i++) { document.getElementById("satpointer" + i).style.display = "none"; document.getElementById("ligpointer" + i).style.display = "none"; } document.getElementById("huepointer" + h.value).style.display = "inline"; document.getElementById("satpointer" + s.value).style.display = "inline"; document.getElementById("ligpointer" + l.value).style.display = "inline"; document.getElementById("linktocp").innerHTML = "