Hướng dẫn how do i display color palette in html? - làm cách nào để hiển thị bảng màu trong html?

W3Schools được tối ưu hóa cho việc học và đào tạo. Ví dụ có thể được đơn giản hóa để cải thiện việc đọc và học tập. Hướng dẫn, tài liệu tham khảo và ví dụ được xem xét liên tục để tránh lỗi, nhưng chúng tôi không thể đảm bảo tính chính xác đầy đủ của tất cả các nội dung. Trong khi sử dụng W3Schools, bạn đồng ý đã đọc và chấp nhận các điều khoản sử dụng, cookie và chính sách bảo mật của chúng tôi.

Bản quyền 1999-2022 bởi dữ liệu refsnes. Đã đăng ký Bản quyền. W3Schools được cung cấp bởi W3.CSS.
W3Schools is Powered by W3.CSS.

❮ thuộc tính loại HTML

Thí dụ

Hiển thị bộ chọn màu (với giá trị màu đỏ được xác định trước):

Chọn màu yêu thích của bạn:

Hãy tự mình thử »


Định nghĩa và cách sử dụng

xác định một bộ chọn màu.

Giá trị mặc định là #000000 (màu đen). Giá trị phải có ký hiệu thập lục phân bảy ký tự.

Mẹo: Luôn thêm thẻ để thực hành khả năng truy cập tốt nhất! Always add the tag for best accessibility practices!


Hỗ trợ trình duyệt

Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ phần tử.

Thuộc tính
loại = "màu"20.0 38.0 29.0 10.1 11.01

Cú pháp


❮ thuộc tính loại HTML


Các phần tử của loại

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
0 cung cấp phần tử giao diện người dùng cho phép người dùng chỉ định màu, bằng cách sử dụng giao diện chọn màu trực quan hoặc bằng cách nhập màu vào trường văn bản ở định dạng thập lục phân
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
1.
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
0
provide a user interface element that lets a user specify a color, either by using a visual color picker interface or by entering the color into a text field in
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
1 hexadecimal format.

Chỉ cho phép các màu đơn giản (không có kênh alpha) mặc dù màu CSS có nhiều định dạng hơn, ví dụ: Tên màu, ký hiệu chức năng và định dạng thập lục phân với kênh alpha.

Trình bày của phần tử có thể thay đổi đáng kể từ một trình duyệt và/hoặc nền tảng khác, nó có thể là một đầu vào văn bản đơn giản tự động xác thực để đảm bảo rằng thông tin màu được nhập theo định dạng phù hợp hoặc một trình chọn màu tiêu chuẩn nền tảng hoặc một số loại của cửa sổ chọn màu tùy chỉnh.

Thử nó

Giá trị

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
2 của phần tử loại
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
0 luôn là một chuỗi chứa chuỗi 7 ký tự chỉ định màu RGB ở định dạng hexadecimal. Mặc dù bạn có thể nhập màu ở trường hợp trên hoặc dưới, nó sẽ được lưu trữ ở dạng trường hợp thấp. Giá trị không bao giờ ở bất kỳ hình thức nào khác, và không bao giờ trống.

LƯU Ý: Đặt giá trị thành bất cứ thứ gì không phải là màu RGB hợp lệ, hoàn toàn, theo ký hiệu thập lục phân sẽ dẫn đến giá trị được đặt thành

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
5. Cụ thể, bạn không thể sử dụng tên màu được tiêu chuẩn hóa của CSS hoặc bất kỳ cú pháp chức năng CSS nào, để đặt giá trị. Điều này có ý nghĩa khi bạn ghi nhớ rằng HTML và CSS là các ngôn ngữ và thông số kỹ thuật riêng biệt. Ngoài ra, màu sắc với kênh alpha không được hỗ trợ; Chỉ định một màu trong ký hiệu thập lục phân 9 ký tự (ví dụ:
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
6) cũng sẽ dẫn đến màu được đặt thành
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
5.
Setting the value to anything that isn't a valid, fully-opaque, RGB color in hexadecimal notation will result in the value being set to
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
5. In particular, you can't use CSS's standardized color names, or any CSS function syntax, to set the value. This makes sense when you keep in mind that HTML and CSS are separate languages and specifications. In addition, colors with an alpha channel are not supported; specifying a color in 9-character hexadecimal notation (e.g.
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
6) will also result in the color being set to
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
5.

Sử dụng đầu vào màu

Đầu vào loại

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
0 rất đơn giản, do số lượng thuộc tính giới hạn mà chúng hỗ trợ.

Cung cấp màu mặc định

Bạn có thể cập nhật ví dụ đơn giản ở trên để đặt giá trị mặc định, do đó màu sắc được lấp đầy trước với màu mặc định và bộ chọn màu (nếu có) cũng sẽ mặc định với màu đó:

<input type="color" value="#ff0000" />

Nếu bạn không chỉ định giá trị, mặc định là

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
5, có màu đen. Giá trị phải ở ký hiệu thập lục phân bảy ký tự, có nghĩa là ký tự "#" theo sau là hai chữ số mỗi chữ số đại diện cho màu đỏ, xanh lá cây và xanh lam, như thế này:
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
1. Nếu bạn có màu ở bất kỳ định dạng nào khác (chẳng hạn như tên màu CSS hoặc các hàm màu CSS như
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
1 hoặc
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
2), bạn sẽ phải chuyển đổi chúng thành thập lục phân trước khi đặt
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
2.

Theo dõi thay đổi màu sắc

Như trường hợp với các loại khác, có hai sự kiện có thể được sử dụng để phát hiện các thay đổi đối với giá trị màu:

<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
5 và
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
6.
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
5 được bắn vào phần tử mỗi khi màu thay đổi. Sự kiện
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
6 được bắn khi người dùng loại bỏ bộ chọn màu. Trong cả hai trường hợp, bạn có thể xác định giá trị mới của phần tử bằng cách xem
colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
2 của nó.

Dưới đây là một ví dụ về việc xem các thay đổi theo thời gian theo giá trị màu:

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}

Chọn giá trị

Khi trình duyệt không hỗ trợ giao diện chọn màu, việc triển khai đầu vào màu của nó sẽ là một hộp văn bản xác thực nội dung tự động để đảm bảo rằng giá trị ở định dạng chính xác. Trong trường hợp này, bạn có thể sử dụng phương thức

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
1 để chọn văn bản hiện tại trong trường chỉnh sửa.

Nếu trình duyệt thay vào đó sử dụng màu tốt,

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
1 không làm gì cả. Bạn nên biết về hành vi này để mã của bạn có thể trả lời một cách thích hợp trong cả hai trường hợp.

Thẩm định

Giá trị của đầu vào màu được coi là không hợp lệ nếu tác nhân người dùng không thể chuyển đổi đầu vào của người dùng thành ký hiệu hình lục giác phụ kiện bảy tính năng bảy ký tự. Nếu và khi đây là trường hợp, pseudo-class

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
3 được áp dụng cho phần tử.

Thí dụ

Chúng ta hãy tạo một ví dụ thực hiện thêm một chút với đầu vào màu bằng cách theo dõi các sự kiện

<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
6 và
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
5 để lấy màu mới và áp dụng nó cho mọi yếu tố
let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
6 trong tài liệu.

HTML

HTML khá đơn giản - một vài đoạn của tài liệu mô tả với loại

colorPicker.addEventListener("input", updateFirst, false);
colorPicker.addEventListener("change", watchColorPicker, false);

function watchColorPicker(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}
0 với ID
let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
9, chúng ta sẽ sử dụng để thay đổi màu của văn bản của đoạn văn.

<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>

JavaScript

Đầu tiên, có một số thiết lập. Ở đây chúng tôi thiết lập một số biến, thiết lập một biến chứa màu mà chúng tôi sẽ đặt màu tốt khi lần đầu tiên tải lên, sau đó thiết lập trình xử lý

function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
0 để thực hiện công việc khởi động chính khi trang được tải đầy đủ.

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);

Khởi tạo

Khi trang được tải, trình xử lý sự kiện

function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
0 của chúng tôi,
function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
2, được gọi là:

function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}

Điều này có một tham chiếu đến phần tử màu trong một biến có tên là

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
9, sau đó đặt giá trị đầu vào màu thành giá trị trong
function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
5. Sau đó, sự kiện
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
5 của đầu vào được thiết lập để gọi hàm
function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
7 của chúng tôi và sự kiện
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
6 được đặt để gọi
function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
9. Cả hai đều được nhìn thấy dưới đây.

Cuối cùng, chúng tôi gọi

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
1 để chọn nội dung văn bản của đầu vào màu nếu điều khiển được thực hiện dưới dạng trường văn bản (điều này không có hiệu lực nếu giao diện chọn màu được cung cấp thay thế).

Phản ứng với sự thay đổi màu sắc

Chúng tôi cung cấp hai chức năng liên quan đến thay đổi màu sắc. Hàm

function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
7 được gọi để đáp ứng với sự kiện
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
5. Nó thay đổi màu của phần tử đoạn đầu tiên trong tài liệu để phù hợp với giá trị mới của đầu vào màu. Vì các sự kiện
<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
5 được bắn mỗi khi điều chỉnh được thực hiện theo giá trị (ví dụ: nếu độ sáng của màu được tăng lên), chúng sẽ xảy ra nhiều lần khi sử dụng bộ chọn màu.

function updateFirst(event) {
  const p = document.querySelector("p");
  if (p) {
    p.style.color = event.target.value;
  }
}

Khi bộ chọn màu bị loại bỏ, chỉ ra rằng giá trị sẽ không thay đổi nữa (trừ khi người dùng mở lại bộ chọn màu), một sự kiện

<p>
  An example demonstrating the use of the
  <code><input type="color">code> control.
p>

<label for="colorWell">Color:label>
<input type="color" value="#ff0000" id="colorWell" />

<p>
  Watch the paragraph colors change when you adjust the color picker. As you
  make changes in the color picker, the first paragraph's color changes, as a
  preview (this uses the <code>inputcode> event). When you close the color
  picker, the <code>changecode> event fires, and we detect that to change
  every paragraph to the selected color.
p>
6 được gửi đến phần tử. Chúng tôi xử lý sự kiện đó bằng hàm
function startup() {
  colorWell = document.querySelector("#colorWell");
  colorWell.value = defaultColor;
  colorWell.addEventListener("input", updateFirst, false);
  colorWell.addEventListener("change", updateAll, false);
  colorWell.select();
}
9, sử dụng
function updateFirst(event) {
  const p = document.querySelector("p");
  if (p) {
    p.style.color = event.target.value;
  }
}
6 để có được màu được chọn cuối cùng:

function updateAll(event) {
  document.querySelectorAll("p").forEach((p) => {
    p.style.color = event.target.value;
  });
}

Điều này đặt màu của mỗi khối

let colorWell;
const defaultColor = "#0000ff";

window.addEventListener("load", startup, false);
6 để thuộc tính ____10 của nó phù hợp với giá trị hiện tại của đầu vào màu, được đề cập đến bằng cách sử dụng
function updateFirst(event) {
  const p = document.querySelector("p");
  if (p) {
    p.style.color = event.target.value;
  }
}
9.

Kết quả

Kết quả cuối cùng trông như thế này:

Thông số kỹ thuật

Sự chỉ rõ
HTML Standard # Color-state- (type = color)
# color-state-(type=color)

Tính tương thích của trình duyệt web

Bảng BCD chỉ tải trong trình duyệt

Xem thêm

Làm thế nào để chúng ta hiển thị bảng màu chọn màu trên màn hình?

Lưu ý rằng phím tắt mặc định được sử dụng để kích hoạt bộ chọn màu là Windows Key+Shift+C.Windows Key+Shift+C.

Mã HTML cho văn bản màu là gì?

Mã màu HTML ở định dạng thập lục phân hai chữ số cho màu đỏ, xanh dương và xanh lá cây (#RRBBGG).Mã màu thập lục phân đi từ 00 đến DD.Ví dụ: #FF0000 sẽ có màu đỏ và #40E0D0 sẽ có màu ngọc lam.(#RRBBGG). Hexadecimal color codes go from 00 to DD. For example, #FF0000 would be red and #40E0D0 would be turquoise.

Làm thế nào để bạn thêm các giá trị RGB trong HTML?

Một ví dụ khác, RGB (0, 255, 0) được hiển thị dưới dạng màu xanh lá cây, vì màu xanh lá cây được đặt thành giá trị cao nhất của nó (255) và hai cái còn lại (màu đỏ và xanh) được đặt thành 0. Để hiển thị màu đen, đặt tất cả các tham số màuđến 0, như thế này: RGB (0, 0, 0).Để hiển thị màu trắng, đặt tất cả các tham số màu thành 255, như thế này: RGB (255, 255, 255).rgb(0, 0, 0). To display white, set all color parameters to 255, like this: rgb(255, 255, 255).