Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is -webkit-link a valid color for any html element or css property for which color is relevant?

Tags:

css

colors

webkit

On one of my applications I noticed Chrome was automatically setting link colors as the color "-webkit-link" via this rule:

/* Not set by my CSS stylesheet */

a:-webkit-any-link {
    color: -webkit-link;
    text-decoration: underline;
    cursor: auto;
}

It is much easier for me to remember a default link color as -webkit-link than a hex code.

I tried setting the color of text wrapped in a p tag and a div tag and this seemed to work fine on Codepen.

div, p { color: -webkit-link; }

Is "-webkit-color" a valid color for wherever a color is relevant? (I could test every possible circumstance for which color is valid but I don't have time). For example, would this rule give a "link blue" border color?

div { border: 2px solid -webkit-link; }

or this rule set a linear-gradient with "link blue"?

div { background-image: linear-gradient(135deg, red 60%, -webkit-link 60%); }

or this rule set a box-shadow with a "link blue" color?

div { box-shadow: inset 2px 2px 2px 4px -webkit-link; }

and endless others which use color?

like image 510
The One and Only ChemistryBlob Avatar asked May 31 '16 17:05

The One and Only ChemistryBlob


People also ask

What is a valid color in HTML?

Web Standard Color Names The World Wide Web Consortium (W3C) has listed 16 valid color names for HTML and CSS: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. Note: Different browsers may display different colors for the same color name.

What is the color property in CSS is used to set the color of HTML elements?

The color CSS property sets the foreground color value of an element's text and text decorations, and sets the currentcolor value. currentcolor may be used as an indirect value on other properties and is the default for other color properties, such as border-color .

What is the use of color property in CSS?

The color property in CSS is used to set the color to text, the background of the webpage, and also to set the color of borders. 2. color-name: By directly specify the name of the color like blue, green, yellow, white, black, etc.


1 Answers

No, -webkit-link is not a valid color.

While it does work anywhere you can use a color, it is not in any standard, and neither Apple nor any of the maintainers of the Blink engine have any obligation to keep it working. There's no guarantee.

In addition, it doesn't work in other browsers. For Firefox, there's -moz-hyperlinkText, but the same disclaimers apply.

(MDN has a page where the Mozilla colors are described, but there doesn't seem to be a similar official page for Webkit. Let that be a warning.)

like image 79
Mr Lister Avatar answered Sep 23 '22 03:09

Mr Lister