Online rgb to hsl converter tool

Below RGB to HSL converter takes input as Red, Green, and Blue(i.e r, g, b values fall within the range 0-255)and then convert input(RGB color)
to a HSL color code, you can also select the color using color picker by clicking on the blue icon.

Enter red color (R):

Enter green color (G):
Enter blue color (B):
Hue (H): °
Saturation (S): %
Lightness (L): %
Color preview:

RGB to HSL conversion

If you are a web developer looking to develop an RGB to HSL color picker tool.below you can find the javascript code.HSL (hue, saturation, lightness) is alternative representations of the RGB color system model.

rgb to hsl javascript function

<script type="text/javascript">
            function rgbtohsl(r, g, b) {
        if (r == "") r = 0;
        if (g == "") g = 0;
        if (b == "") b = 0;
                r = parseFloat(r);
                g = parseFloat(g);
                b = parseFloat(b);
        if (r < 0) r = 0;
        if (g < 0) g = 0;
        if (b < 0) b = 0;
        if (r > 255) r = 255;
        if (g > 255) g = 255;
        if (b > 255) b = 255;
                hex = r * 65536 + g * 256 + b;
                hex = hex.toString(16, 6);
                len = hex.length;
        if (len < 6)
        for (i = 0; i < 6 - len; i++)
                        hex = '0' + hex;
                r /= 255;
                g /= 255;
                b /= 255;
                M = Math.max(r, g, b);
                m = Math.min(r, g, b);
                d = M - m;
        if (d == 0) h = 0;
        else if (M == r) h = ((g - b) / d) % 6;
        else if (M == g) h = (b - r) / d + 2;
        else h = (r - g) / d + 4;
                h *= 60;
        if (h < 0) h += 360;
                l = (M + m) / 2;
        if (d == 0)
                    s = 0;
                    s = d / (1 - Math.abs(2 * l - 1));
                s *= 100;
                l *= 100;
                h = h.toFixed(0);
                s = s.toFixed(1);
                l = l.toFixed(1);

Everyone likes a beautiful and attractive looking website. You can do this by using CSS. So today we will tell you,What is the use of CSS in web designing? Why is it important to learn this?
Cascading style sheets are a type of language that we use to designing our website. Simply we can say, CSS tells your browser what the font, color, size, position, etc. of the web page.Without HTML, nothing can be made from HTML CSS, so you need to know HTML.Both HTML and CSS provide a web page look and feel.
HTML provides shapes to a web page and the CSS work is meant to make the web page attractive.
HTML Mean Content, we just put the content from of HTML into our page, content means text, heading, paragraph, image, video, audio, bullet lists etc.the web page structure is also made from HTML.
CSS Mean Design, CSS define the color, background, size, border, position, etc. of that content. This CSS determines how it will look in the content browser.
Let's take we are writing an article on the website that has a heading, title, and paragraphs.
The HTML just tells to browser who is the heading and who is a paragraph, while the CSS tells to the browser what is color and size of the headings and paragraphs.

Design is easy to maintain: if ​​we have created a website using HTML without having to use CSS, which has 50 pages, now we need to have the same design of all pages, we design a page and copy-paste it There are no problems in making 50 pages, after this, we put content in all the pages.
Now the website is ready but at a time of deployment if we have to make some changes in the design, So we have to color the headings of all the pages, then we will have to go through one by one page to make changes which will be a very long time-consuming.
If we use CSS, then this work is very easy, because with CSS we separate the design of the page from the content part, now when we need changes in the design, we can easily go into the CSS file Make changes that apply to the entire website.

The speed of the website increases: If we use Cascading Style Sheets, the speed of the loading of the web page is fast because we create a separate file for CSS and when you visit a page on the website That CSS file is stored in your browser cache, then when you go to the second page of the same site, then again your browser will not need to download that CSS file.
But if the CSS does not use and then the page loading will be slow because of the browser will have to understand this CSS every time.
You can see that the design of some sites is different on desktop and different in the mobile device, that is because we control the design according to the device, they tell the browser what to show if the device is mobile and if the device is a desktop.

The post rgb to hsl converter-best online tool appeared first on Software Development | Programming Tutorials.