HTML: Definer farvekoder - hvordan det fungerer
Du kan definere farver i HTML på forskellige måder. Vi viser dig, hvordan du gør dette.
Definer farvekoder i HTML
Grundlæggende kan du definere farver i HTML på to måder - enten med farvenavne eller hexkoder. Farvenavne er mere mindeværdige, men de fleste webudviklere bruger hexcoder til at kode farverne:
- Hexcode: Det hexadecimale antal har altid seks cifre til farvekodning. De to første cifre står for den røde komponent, de næste to for grøn og de sidste to for den blå komponent. Der er altid et diamantskilt foran en farve: "#". Så du kan definere en rød baggrundsfarve som denne: "". Bemærk, at stavemåden er forældet uden typografiark. Undgå for eksempel denne kode: "".
- Farvenavne: De fungerer dybest set på samme måde som hex-koder. Du kan oprette en rød baggrund som denne: "". Du kan finde detaljerede tabeller med hundreder af farvenavne på Internettet.
Det er mere professionelt at flytte farvedefinitionerne til et eksternt stilark (CSS). I et andet praktisk tip forklarer vi forskellene mellem HTML og CSS.