Due to this question I need to find the color codes for
green
, red
and yellow
so I can translate them into the decimal number used by the rgba()
function. From this site I think green is #008000
which would be rgb(0, 128, 0). But I'd be interested in finding the official source. They didn't appear to be in the CSS spec. Any ideas where they would be?Community♦
AJPAJP
3 Answers
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java. Generate a nice color gradient. Just enter two colors and our tool generates a perfect color gradient and the fitting css code. ColorSpace - CSS Gradient Color Generator.
They can be found in CSS
<color>
definition:The list of color keywords is: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, and yellow
Tim CooperTim Cooper
You'll find this site useful http://www.quackit.com/html/codes/color/color_names.cfm
The following table contains the color names that are recognized by most, if not all, modern browsers. Most of these are from the list of X11 color names distributed with the X Window System. These color names were standardized by SVG 1.0.
KaneKane
Worth pointing out that the specification extends beyond the basic colour keywords referenced by @Tim Cooper and contains some of the more creative (or, rather, SVG spec names) like 'aliceblue' and ' lightgoldenrodyellow'
w3 docos contain both the color names and their synonimous hex and rgb values which you may find useful for your task
o.v.o.v.
Not the answer you're looking for? Browse other questions tagged css or ask your own question.
Good typographic design is an important part of a successful website. CSS gives you great control over the appearance of text on the web pages you build. This includes the ability to change the color of any fonts that you use.
Below, we'll look at changing the font color using an external style sheet and a style that's used in a paragraph tag. You can apply the same style property to change the font color on any tag that surrounds text, including the <body> tag.
![Css color codes blue Css color codes blue](/uploads/1/2/5/1/125130711/595656022.gif)
![Css Color Codes Css Color Codes](/uploads/1/2/5/1/125130711/959059515.jpg)
Adding Styles to Change Font Color
- For this example, you need to have an HTML document to see the CSS changes and a separate CSS file that's attached to that document. We're going to look at the paragraph element, specifically.
- To change the text color for every paragraph in your HTML file, go to the external style sheet and type p { }. Place the color property in the style followed by a colon, like p { color: }. Then, add your color value after the property, ending it with a semicolon: p { color: black;}.Color values can be expressed as color keywords, RGB color numbers, or hexadecimal color numbers. In our example, the paragraph text is changed to the color black.
- However, if you want to change the text color to green, blue, red, etc., using color keywords will not give you the flexibility you might want to create different shades. That's where hexadecimal values come in to play.This CSS style can be used to color your paragraphs black because the hex code #000000 translates to black. You could even use shorthand with that hex value and write it as #000 with the same results.
- Like we mentioned above, hex values work well when you need a color that isn't simply black or white. The above CSS hex value would set the paragraphs to a blue color, but unlike the keyword 'blue', this hex code gives you the ability to set a very specific shade of blue, a mid-range, slate-like blue in this case.Hex works by setting the RGB(red, green, blue) values of a color separately with base-sixteen values. That's why they contain the letters A through F in addition to the digits 0 through 9.Each color, red, green, and blue, receives its own two-digit value. 00 is the lowest value possible, while FF is the highest. The colors are listed in RGB order in a hex, so the first two digits represent the red value and so on.
- Finally, you can use RGBA color values for font colors as well. RGCA is supported in all modern browsers, so you can use these values with confidence that it'll work for most viewers, but you can also set an easy fallback.This RGBA value is the same as the slate blue color specified earlier. The first three values set the Red, Green, and Blue values and the final number is the alpha setting for transparency. The alpha setting is set to 1 to mean 100 percent, so this color has no transparency. If you set that value to a decimal number, like .85, it translates to 85 percent opacity and the color would be slightly transparent.If you want to bulletproof your color values, mimic the above CSS code. This syntax sets the hex code first and then overwrites that value with the RGBA number. This means that any older browser that does not support RGBA will get the first value and ignore the second.
- It's important to keep in mind that the color property works on any HTML text element in CSS. You can, for example, change all your link colors.The example above would make your links bright green.You this works with multiple elements at once too. You can set every title level at once.That would set all of your title elements to a midnight blue color.
- Coming up with the hex or RGBA values for your colors isn't always easy. Most web designers will use their image editing program, like Photoshop or GIMP to generate the exact codes. You can also find convenient color picker tools online, like this one from w3schools.
Other Ways to Style an HTML Page
Font colors can be changed with an external style sheet, an internal style sheet, or inline styling within the HTML document. However, best practices dictate that you should use an external style sheet for your CSS styles.
An internal style sheet, which are styles written directly in the 'head' of your document, are generally only used for small, one-page websites. Inline styles should be avoided since they are akin to the old 'font' tags that we dealt with many years ago. Those inline styles make it very hard to manage font style since you have to change them at every instance of the inline style.