Proprietà colore CSS
Esempio
Imposta il colore del testo per diversi elementi:
body
{
color: red;
}
h1
{
color: #00ff00;
}
p.ex
{
color: rgb(0,0,255);
}
Altri esempi "Provalo da solo" di seguito.
Definizione e utilizzo
La color
proprietà specifica il colore del testo.
Suggerimento: usa un colore di sfondo combinato con un colore del testo che renda il testo facile da leggere.
Valore di default: | non specificato |
---|---|
Ereditato: | sì |
Animabile: | sì. Leggi su animabile |
Versione: | CSS1 |
sintassi JavaScript: | oggetto .style.color="#0000FF" |
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente la proprietà.
Property | |||||
---|---|---|---|---|---|
color | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
Sintassi CSS
color: color|initial|inherit;
Valori di proprietà
Value | Description | Play it |
---|---|---|
color | Specifies the text color. Look at CSS Color Values for a complete list of possible color values. | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Altri esempi
Esempio
Imposta il colore del testo con un valore HEX:
body {color: #92a8d1;}
Esempio
Imposta il colore del testo con un valore RGB:
body {color: rgb(201, 76, 76);}
Esempio
Imposta il colore del testo con un valore RGBA:
body {color: rgba(201, 76, 76, 0.6);}
Esempio
Imposta il colore del testo con un valore HSL:
body {color: hsl(89, 43%, 51%);}
Esempio
Imposta il colore del testo con un valore HSLA:
body {color: hsla(89, 43%, 51%, 0.6);}
Pagine correlate
Tutorial CSS: testo CSS
Riferimento HTML DOM: proprietà del colore