- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS Function - hwb()
The hwb() function in CSS is used to define a color using the red, green, and blue color channels, as per the hue, whiteness and blackness components of these color channels. It allows you to specify a color by specifying the intensity of each of these three primary colors.
To add the color transparency, an optional alpha component can be passed to the hwb() function.
Possible values
The functional notation for hwb() function is hwb(H W B[ / A]).
H: can contain either of the format(s), that represents the hue angle :
a <number>: any number between 0 and 255.
an <angle>: any value between 0deg and 360deg.
keyword none
W: can contain either of the format(s), that represents the whiteness:
a <percentage>: specifies the amount of white to mix in. Can have any value between 0% (no whiteness) and 100% (full whiteness).
keyword none
B: can contain either of the format(s), that represents the blackness:
a <percentage>: specifies the amount of black to mix in. Can have any value between 0% (no blackness) and 100% (full blackness).
keyword none
A: represents the transparency of the color. It is an optional value.
<alpha-value>: any number between 0 and 1, where 1 corresponds to full opacity and 0 corresponds to full transparency.
keyword none
The values of the red, green and blue components are rounded in serialization, as the functional notation serializes it as sRGB.
Syntax
hwb(154 25% 50%) | hwb(154deg, 25%, 50%) | hwb(154 25% 50% / 0.5)
CSS hwb() - Using conic-gradient()
Following is an example showing the usage of hwb() function in a conic-gradient() function:
<html> <head> <style> div { width: 100px; height: 100px; border: 2px solid black; margin-bottom: 10px; } .hwb-conic{ background: conic-gradient(hwb(270 100% 50%), hwb(80 20% 20%), hwb(0 30% 10% / 0.7), hwb(194 0% 0%)); } </style> </head> <body> <p>hwb() with conic-gradient()</p> <div class="hwb-conic"></div> </body> </html>
CSS hwb() - With or Without alpha value
Following is an example showing the usage of hwb() function where all the three values are passed with and without the alpha value (number values):
<html> <head> <style> div { width: 100px; height: 100px; border: 2px solid black; margin-bottom: 10px; } .color-hwb-1{ background-color: hwb(70deg 60% 80%); } .color-hwb-2{ background-color: hwb(80 20% 20%); } .color-hwb-alpha-number{ background-color: hwb(0 30% 10% / 0.7); } .color-hwb-alpha-percent{ background-color: hwb(194 0% 0% / 100%); } </style> </head> <body> <div class="color-hwb-1">hwb(70deg 60% 80%)</div> <div class="color-hwb-2">hwb(80 ,20%, 20%)</div> <div class="color-hwb-alpha-number">hwb(0 30% 10% / 0.7)</div> <div class="color-hwb-alpha-percent">hwb(194 0% 0% / 100%)</div> </body> </html>
To Continue Learning Please Login
Login with Google