Einführung in HTML-Farben

In diesem Artikel wird erläutert, wie Sie mithilfe von HTML auf einfache Weise Farben in der Website verwenden. Farben spielen eine wichtige Rolle bei der Erstellung von Websites, die gut aussehen und sich gut anfühlen. In HTML ist kein einzelnes Tag integriert. Stattdessen werden das style-Attribut oder die color-Eigenschaft verwendet. Genau genommen werden die Farben mithilfe von Cascading Style Sheet (CSS) in die HTML-Elemente eingebettet. Farben verleihen der Webseite ein elegantes Aussehen. Das Hinzufügen von Farben zur Webseite umfasst das Festlegen von Hintergrundfarben, Tabellen, Absätzen usw.

Wie stelle ich eine Hintergrundfarbe in HTML ein?

Wenn Sie die Hintergrundfarbe aufhellen, sieht die Website hübsch und mutig aus. Dazu werden Farben und Hex-Farbcodes verwendet. RGB- und RGBA-Farbwerte (Alpha-Wert 0 bis 1).

Die hexadezimale Farbe wird mithilfe des Style-Attributs im body-Element des HTML-Codes direkt auf den HTML-Code angewendet. Hex ist eine Kombination aus Zahlen und Buchstaben. Das folgende Beispiel zeigt die Hintergrundfarbe auf der Webseite.

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

Code Ausschnitte:

Um Hintergrundfarbe hinzuzufügen, können Sie das Attribut bgcolor zum Anzeigen verwenden. Es ist mit allen Browsern außer HTML 5 kompatibel.

Color Name
Hexadecimal
RGB Value

Color Name
Hexadecimal
RGB Value

Color Name
Hexadecimal
RGB Value

Color Name
Hexadecimal
RGB Value

Color Name
Hexadecimal
RGB Value

Wie wende ich Farbe auf Text in HTML an?

Das Anwenden von Farben auf den HTML-Text ist recht einfach. Sie können die Farbe des Texts hinzufügen / ändern, indem Sie drei Methoden anwenden, nämlich Hex-Farbe, HSL-Werte und Farbnamen. Im Folgenden sind die drei verschiedenen Techniken zum Anwenden von Farben auf die entsprechenden Webseiten aufgeführt.

1. Farbnamen

Dies ist recht einfach, wenn englische Farbnamen verwendet werden, wenn die Anwendung einfach ist, werden diese Farbnamen verwendet. Die Angabe der Farbnamen erfolgt direkt und W3C hat 16 Grundfarben angekündigt (Schwarz, Gelb, Rot, Kastanienbraun, Grau, Limette, Grün, Olive, Silber, Aqua, Blau, Marine, Weiß, Lila, Fuchsia, Blaugrün).

2. HSL

Farbton Sättigung und Helligkeit Farbwerte. Der Farbton wird in 0 bis 360 Grad, die Sättigung und die Helligkeit in einem Bereich von 0 bis 100% definiert.

3. Hex Farbe

Um ein genaues Ergebnis zu erhalten, wird eine sechsstellige Hexadezimalzahl verwendet. Um die ersten zwei Ziffern für Rot zu erläutern, bezeichnen die nächsten zwei für Grün, die anderen beiden für Blau und mit einem vorangestellten '#'.

Im folgenden Beispiel werden die verschiedenen Möglichkeiten zum Anwenden von Farben auf die Dokumente erläutert.


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

Ausgabe:

Es gibt verschiedene Methoden, um Textfarben zu erstellen, da HTML viele anpassbare Anwendungen bietet.

  1. Anwenden des Style-Abschnitts
  2. Erstellen eines individuellen CSS Stylesheets
  3. Text umschließen

Wie wende ich die Textfarbe mit Hilfe des Abschnitts an?

Sehen wir uns verschiedene Methoden für die Verwendung von HTML-Farben an:

1. Umhüllen mit HTML-Farben

Der folgende Code ändert die Farbe des Textes im Absatz mit einfachen HTML-Codes. Es gibt 140 farbige Namen, um die Websites zu färben. Der folgende Code zeigt, wie die Textfarbe mithilfe von Abschnitten angewendet wird.


Text color

HTML BG Color

changing text color


Text color

HTML BG Color

changing text color


Text color

HTML BG Color

changing text color

Dieser Inhalt ist sehr klar

rosa Absatztext

Ausgabe:

2. HEXCOLOR verwenden

Auch in diesem Beispiel wird der Abschnitt style verwendet, um hexadezimale Farben zu deklarieren, gefolgt von einem # -Symbol.



Color Picker

changing text color



Color Picker

changing text color



Color Picker

changing text color

Hallo Welt

Hexa-Absatztext

Ausgabe:

3. RGB-Farbe verwenden

Für Rot, Grün und Blau werden jeweils 8 Bits verwendet, und ihr Wert variiert von 0 bis 255, wodurch verschiedene Farben erzeugt werden. Im folgenden Beispiel wird die RGB-Farbe anhand ihrer Werte ausgewählt.



Color Picker

Blauer Absatztext

Ausgabe:

4. Methode unter Verwendung des Stylesheets



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

Jedes Tag mit Farben gestylt werden.

Ausgabe:

5. Erstellen eines individuellen CSS-Stils

HTML-Datei




CSS style sheet




CSS style sheet




CSS style sheet

Mehrere HTML-Dokumente.

Hallo Welt!

Externe CSS-Datei lcolor.css

.lcolor ( font-size: 40px;
color:red )

Ausgabe:

Wie setze ich die Rahmenfarbe in HTML?

Es wird ein Attribut border color = "" verwendet. Dies geschieht mit dem Html-Element

und sogar wir können 3D-Effekte erstellen. Die Rahmenfarbe wird mit verschiedenen Attributen wie border = "width", bordercolor = "color def", bordercolorlight = "" angewendet. CSS verfügt über einige erweiterte Rahmeneigenschaften, die beim Erstellen von Rahmen hilfreich sind. Das folgende Beispiel zeigt das Festlegen einer einzelnen Rahmenfarbe für die entsprechende Tabelle. Hier bezeichnet die Tabellenzeile und
bezeichnet Tabellendaten und wird mit gestartet Etikett. Und der Rahmen für sie wird unter Verwendung ihrer Breite und Farben angewendet




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California




Chicago
new york
Texas
California

Ausgabe:

Nun sehen wir, wie zwei Rahmenfarben separat eingestellt werden. Der folgende Code verwendet das Tabellenattribut mit seinen Elementen.



Samsung Nokia Apple Iphone Xiami Redmi



Samsung Nokia Apple Iphone Xiami Redmi


Samsung Nokia Apple Iphone Xiami Redmi


Samsung Nokia Apple Iphone Xiami Redmi


Samsung Nokia Apple Iphone Xiami Redmi


Samsung Nokia Apple Iphone Xiami Redmi

Ausgabe:

Tag verwenden

Es wird verwendet, um alle Elemente zu gruppieren, und hilft bei der Anzeige einer Webseite an ihrer bestimmten Position. Im folgenden Code haben wir zwei verwendet, einen für einen Absatz und einen anderen, um das Stilattribut durch Festlegen von Randpixeln zu implementieren, und die Dicke wird durch Ausgeben der Breite erhöht, und wir haben Auffüllungen hinzugefügt, um sie links zu veranschaulichen.



Sample border color using div

Natur ist wunderschön

div mit einer Randfarbe.

Ausgabe:

Beispiel: In diesem Beispiel wird erläutert, wie Sie die Farbe für Auffüllung und Rand mithilfe von Klassen- und Listen-Tags festlegen.



Borders
UL (
background: Green;
margin: 10px 10px 5px 5px;
padding: 4px 4px 4px 4px;
)
LI (
color: red;
background:yellow;
margin: 11px 11px 7px 6px;
padding: 10px 0px 10px 10px;
list-style: none
)
LI.colorbord (
border-style: dashed;
border-width: small;
border-color: orange;
)


DOM model
Document object model helps in creating document tree



    Borders
    UL (
    background: Green;
    margin: 10px 10px 5px 5px;
    padding: 4px 4px 4px 4px;
    )
    LI (
    color: red;
    background:yellow;
    margin: 11px 11px 7px 6px;
    padding: 10px 0px 10px 10px;
    list-style: none
    )
    LI.colorbord (
    border-style: dashed;
    border-width: small;
    border-color: orange;
    )


    DOM model
    Document object model helps in creating document tree



  • Borders
    UL (
    background: Green;
    margin: 10px 10px 5px 5px;
    padding: 4px 4px 4px 4px;
    )
    LI (
    color: red;
    background:yellow;
    margin: 11px 11px 7px 6px;
    padding: 10px 0px 10px 10px;
    list-style: none
    )
    LI.colorbord (
    border-style: dashed;
    border-width: small;
    border-color: orange;
    )


    DOM model
    Document object model helps in creating document tree



  • Borders
    UL (
    background: Green;
    margin: 10px 10px 5px 5px;
    padding: 4px 4px 4px 4px;
    )
    LI (
    color: red;
    background:yellow;
    margin: 11px 11px 7px 6px;
    padding: 10px 0px 10px 10px;
    list-style: none
    )
    LI.colorbord (
    border-style: dashed;
    border-width: small;
    border-color: orange;
    )


    DOM model
    Document object model helps in creating document tree



Borders
UL (
background: Green;
margin: 10px 10px 5px 5px;
padding: 4px 4px 4px 4px;
)
LI (
color: red;
background:yellow;
margin: 11px 11px 7px 6px;
padding: 10px 0px 10px 10px;
list-style: none
)
LI.colorbord (
border-style: dashed;
border-width: small;
border-color: orange;
)


DOM model
Document object model helps in creating document tree

Ausgabe:

Wie spezifiziere ich Farbe mit Werten in HTML?

Die Grundfarbwerte variieren von 0 bis 255 für Rot, Blau und Grün. Der Farbwert ist wichtig für das Ausgeben der Helligkeit.

Die folgende Tabelle zeigt Beispielwerte für die Farben

Beispiel: Das folgende Beispiel zeigt verschiedene Farbwerte in ihren Hintergrundeinstellungen.



Bei Data Mining-Techniken geht es darum, Muster zu verstehen

Einstufung


Prognose


Regression


Klassifikation, Vorhersagetechniken

HTML-Farben


Tischfarben

Ausgabe:

Wie verwende ich RGB-Farbwerte in HTML?

RGB bezeichnet direkt die Farben Rot, Grün und Blau und verwendet die RGB-Funktion. Diese drei Werte werden als Parameter verwendet und manchmal in Prozent als Ganzzahl deklariert. Unabhängig von der gewünschten Farbe erhält die Intensität einen höheren Wert von 255, wenn ein ganzzahliger Wert zwischen 0 und 255 liegt. Um beispielsweise eine blaue Farbe zu erhalten, wird bevorzugt (0, 0, 255) angegeben. hier sind die ersten beiden Werte als 0, 0 markiert und der letzte Wert ist 255 für blau.

Beispiel: RGB-Farbe



div (
background-color: rgb(255, 0, 180);
color: rgb(0, 255, 255);
padding: 30px;
)

Norway the most beautiful place it's a Scandinavian Country.



div (
background-color: rgb(255, 0, 180);
color: rgb(0, 255, 255);
padding: 30px;
)

Norway the most beautiful place it's a Scandinavian Country.



div (
background-color: rgb(255, 0, 180);
color: rgb(0, 255, 255);
padding: 30px;
)

Norway the most beautiful place it's a Scandinavian Country.

Es ist das teuerste Land der Welt, Oslo ist die Hauptstadt dieser grünen Stadt.

Ausgabe:

Festlegen der Helligkeit von Farben in HTML

Die Helligkeit der Farbe wird durch die Helligkeit definiert, die wir bevorzugen. Sie wird in Prozent gemessen. Die meisten Webdesigner möchten eine geringere Helligkeit als RGB verwenden, die an die jeweiligen Anforderungen angepasst werden kann. Hier setzt ein Schwarz die Helligkeit auf 0%, Weiß auf 100%. Sie wird mit der Funktion hsl () angegeben.



div (
background-color: hsl(150, 50%, 60%);
color: hsl(100%, 0%, 0%);
padding: 30px;
)

Norway the most beautiful place its an Scandinavian Country.



div (
background-color: hsl(150, 50%, 60%);
color: hsl(100%, 0%, 0%);
padding: 30px;
)

Norway the most beautiful place its an Scandinavian Country.



div (
background-color: hsl(150, 50%, 60%);
color: hsl(100%, 0%, 0%);
padding: 30px;
)

Norway the most beautiful place its an Scandinavian Country.

Es ist das teuerste Land der Welt, Oslo ist die Hauptstadt dieser grünen Stadt.

Ausgabe:

Sie können im obigen Beispiel verschiedene Farbwerte ausprobieren.

Fazit

Abschließend haben wir gesehen, dass dies unterschiedliche Eigenschaften hat. In früheren Tagen gab es für die Webentwicklung viele Möglichkeiten, Farben für ihre Website festzulegen, und heutzutage sind RGB- und Hex-Farbcodes die beliebtesten Farbarten (RGB ist allgemein bekannt). Es gibt verschiedene Anwendungen, in denen Farben wie eine Schiebeskala, eine Farbpalette usw. implementiert werden.

Empfohlene Artikel

Dies ist eine Anleitung zu HTML-Farben. Hier wird die Einführung, Festlegen einer Hintergrundfarbe in HTML, Anwenden von Farben auf Text in HTML usw. erläutert. Weitere Informationen finden Sie auch in unseren anderen empfohlenen Artikeln.

  1. HTML-Tabellen-Tags
  2. Erstellen Sie Tabellen in HTML
  3. HTML-Schriftarten
  4. HTML-Formularelemente
  5. Programm zum Erstellen eines HTML-Farbwählers (Beispiel)
  6. Wie implementiere ich Farbe und ändere den Stil in Matlab?
  7. Wie man eine Datei in PHP mit Beispielen hochlädt