Colors HWB

HWB (Hue, Whiteness, Blackness) is a suggested standard for CSS4

HTML Support

HWB is not supported in HTML (yet), but it is suggested as a new standard in CSS4.

While waiting for CSS4, you can include w3resource' Color library, and use HWB as an HTML attribute like this:

Example

<div data-w3-color="hwb(60, 50%, 0)">

<p>London is the capital city of England.
It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>

</div>

<script src="#"></script>

w3resource Color Library

The JavaScript library used in the example above can be downloaded from

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("white01"); } if (e == 2) { x = document.getElementById("black01"); } x.value = n; setColor(x); } } function setColor(elmnt) { var ele, col, h, w, b, rgb, i; h = document.getElementById("hue01"); w = document.getElementById("white01"); b = document.getElementById("black01"); 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";} } if (elmnt.id == "white01") { if (parseInt(w.value) + parseInt(b.value) > 100) { b.value = 100 - parseInt(w.value); } } if (elmnt.id == "black01") { if (parseInt(w.value) + parseInt(b.value) > 100) { w.value = 100 - parseInt(b.value); } } rgb = w3color("hwb(" + h.value + ", " + w.value + "%, " + b.value + "%)"); document.getElementById("result01").style.backgroundColor = rgb.toRgbString(); document.getElementById("hwb01").value = rgb.toHwbString(); document.getElementById("rgb01").innerHTML = rgb.toRgbString(); document.getElementById("hex01").innerHTML = rgb.toHexString(); document.getElementById("hsl01").innerHTML = rgb.toHslString(); for (i = 0; i <= 360; i++) { document.getElementById("huepointer" + i).style.display = "none"; } drawWhiteTable(h.value); drawBlackTable(h.value); for (i = 0; i <= 100; i++) { document.getElementById("whitepointer" + i).style.display = "none"; document.getElementById("blackpointer" + i).style.display = "none"; } document.getElementById("huepointer" + h.value).style.display = "inline"; document.getElementById("whitepointer" + w.value).style.display = "inline"; document.getElementById("blackpointer" + b.value).style.display = "inline"; document.getElementById("linktocp").innerHTML = "


Use this color in our Color Picker

"; } function setFullColor() { var color = w3color(document.getElementById("hwb01").value); var hwb = color.toHwb(); document.getElementById("hue01").value = hwb.h.toFixed(0); document.getElementById("white01").value = (hwb.w * 100).toFixed(0); document.getElementById("black01").value = (hwb.b * 100).toFixed(0); setColor(document.getElementById("hue01")); } color = w3color("ff0000"); document.getElementById("hwb01").value = color.toHwbString(); setFullColor();