Introduzione ai colori HTML
Questo articolo illustra come utilizzare i colori nel sito Web utilizzando HTML in modo semplice e intuitivo. I colori svolgono un ruolo importante nella creazione di siti Web per apparire e sentirsi bene. Non esiste un tag HTML incorporato individuale, ma utilizza l'attributo di stile o la proprietà color. Precisamente, i colori sono incorporati negli elementi HTML usando il CSS (Cascading Style Sheet). I colori danno un aspetto elegante alla pagina web. L'aggiunta di colori alla pagina Web include l'impostazione di colori di sfondo, tabelle, paragrafi, ecc.
Come impostare un colore di sfondo in HTML?
Rendere il colore di sfondo più luminoso rende il sito Web più bello e più audace. Viene fatto usando colori, codici colore esadecimali. Valori di colore RGB e RGBA (valore alfa da 0 a 1).
Il colore esadecimale viene applicato direttamente al codice HTML mediante l'attributo Style all'interno dell'elemento body dell'html. Hex è una combinazione di numeri e lettere. Di seguito è riportato l'esempio che illustra il colore di sfondo nella pagina Web.
My Sample
HTML BG Color
This page is a demo
My Sample
HTML BG Color
This page is a demo
My Sample
HTML BG Color
This page is a demo
My Sample
HTML BG Color
This page is a demo
Frammenti di codice:
Per aggiungere il colore di sfondo è possibile utilizzare l'attributo bgcolor per la visualizzazione. È compatibile con tutti i browser tranne HTML 5.
Color Name
Hexadecimal
RGB Value
Hexadecimal
RGB Value
Color Name
Hexadecimal
RGB Value
Color Name
Hexadecimal
RGB Value
Hexadecimal
RGB Value
Color Name
Hexadecimal
RGB Value
Color Name
Hexadecimal
RGB Value
Hexadecimal
RGB Value
Come applicare il colore al testo in HTML?
Applicare il colore al testo HTML è abbastanza semplice, possiamo aggiungere / cambiare il colore del testo applicando tre modi: colore esadecimale, valori HSL e nomi dei colori. Di seguito sono riportate le tre diverse tecniche per applicare il colore alle pagine Web corrispondenti.
1. Nomi dei colori
Questo è abbastanza semplice usando i nomi dei colori inglesi quando l'applicazione è diretta, vengono usati questi nomi di colori. La specifica dei nomi dei colori è un metodo diretto e il W3C ha annunciato 16 colori di base (nero, giallo, rosso, marrone, grigio, lime, verde, verde oliva, argento, verde acqua, blu, blu scuro, bianco, viola, fucsia, verde acqua)
2. HSL
Valori di saturazione della tonalità e luminosità. La tonalità è definita da 0 a 360 gradi, la saturazione e la luminosità da 0 a 100%.
3. Colore esadecimale
Per ottenere un risultato preciso, viene applicato un numero esadecimale a sei cifre. Per elaborare le prime due cifre indicano il rosso, le due successive indicano il verde, le altre due indicano il valore del blu e precedute da '#'.
L'esempio seguente spiega i diversi modi di applicare i colori ai documenti.
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
EDUCBA
h1(
color:#97cae0;
background-color: hsl(200, 50%, 20%);
color: hsl(200, 20%, 90%);
)
h4(
color:rgb(0, 255, 0);
background-color: hsl(130, 10%, 30%);
color: hsl(280, 20%, 80%);
)
li(
color:rgba(12, 88, 120, 1);
background-color: hsl(210, 36%, 50%);
color: hsl(145, 45%, 81%);
)
EDUCBA
List of operating System
Windows
MACINTOSH
LINUX
UBUNTU
Produzione:
Esistono diversi metodi per fare il colore del testo in quanto HTML ha molte applicazioni personalizzabili.
- Applicazione della sezione Stile
- creando un singolo foglio di stile CSS
- Avvolgere il testo
Come applicare il colore del testo usando la sezione?
Vediamo vari metodi per l'utilizzo dei colori HTML:
1. Avvolgimento con i colori HTML
Sotto il codice cambia il colore del testo nel paragrafo con semplici codici HTML. ci sono 140 nomi colorati per colorare i siti web. Il codice seguente mostra come applicare il colore del testo usando la sezione.
Text color
HTML BG Color
changing text color
Text color
HTML BG Color
changing text color
Text color
HTML BG Color
changing text color
Text color
HTML BG Color
changing text color
Questo contenuto è molto chiaro
testo in paragrafo rosa
Produzione:
2. Utilizzo di HEXCOLOR
Ancora una volta, questo esempio prende la sezione di stile per dichiarare il colore esadecimale seguito da un simbolo '#'.
Color Picker
changing text color
Color Picker
changing text color
Color Picker
changing text color
Color Picker
changing text color
Ciao mondo
Testo del paragrafo esadecimale
Produzione:
3. Utilizzo del colore RGB
Il rosso, il verde e il blu usano 8 bit ciascuno e il loro valore varia da 0 a 255 che produce vari colori. L'esempio seguente seleziona il colore RGB in base ai loro valori.
Color Picker
Testo in paragrafo blu
Produzione:
4. Metodo usando il foglio di stile
Style Sheet in HTML
@import url("/examples/css/style.css");
p (
color: green;
font-size: 26px;
)
The styles for Html documents
Style Sheet in HTML
@import url("/examples/css/style.css");
p (
color: green;
font-size: 26px;
)
The styles for Html documents
Style Sheet in HTML
@import url("/examples/css/style.css");
p (
color: green;
font-size: 26px;
)
The styles for Html documents
Style Sheet in HTML
@import url("/examples/css/style.css");
p (
color: green;
font-size: 26px;
)
The styles for Html documents
Ogni etichetta deve essere abbinata a colori.
Produzione:
5. Creazione di singoli stili CSS
file .html
CSS style sheet
CSS style sheet
CSS style sheet
Documento HTMl multiplo.
Ciao mondo!
File CSS esterno lcolor.css
.lcolor ( font-size: 40px;
color:red )
Produzione:
Come impostare il colore del bordo in HTML?
Viene fatto usando un attributo border color = "“. Viene fatto utilizzando l'elemento HTML