Как изменить цвет в таблице html
Перейти к содержимому

Как изменить цвет в таблице html

  • автор:

Как поменять цвет таблицы в html

Аватар пользователя Вячеслав Межуревский

Для стилизации ячеек таблиц можно использовать как свойства background, так и border.

Исходный HTML документ:

table-css

Рекомендуемые курсы

Похожие вопросы

  • О нас
  • Карьера в Хекслете
  • Хекслет Колледж
  • Условия использования
  • Соглашение об обработке ПД
  • Оферта
  • Акции
  • 8 800 100 22 47 бесплатно по РФ
  • +7 495 085 28 38 бесплатно по Москве
  • support@hexlet.io

ООО «Хекслет Рус» 432071, г. Ульяновск, пр-т Нариманова, дом 1Г, оф. 23 ОГРН 1217300010476

HTML Table Background Color

This page contains HTML table background color code. These are HTML codes for specifying or changing the background color of your tables within your blog or web page.

In HTML, table background color is specified using Cascading Style Sheets (CSS). In particular, you use the CSS background-color property to set the background color for your table. You can also specify a separate background color for your table rows and table cells if you like.

Background Color for the Whole Table

To change the background color of the whole table, use the background-color property against the table tag.

Background Color of a Table Row

To change the background color of a table row, you apply the same code, but to the table row in question (i.e. the tr tag).

Here we also use border-collapse:collapse; to collapse the border.

Background Color of a Single Cell

To change the background color of a single table cell, you apply the same code, but to the table cell in question (i.e. the td tag or the th tag, depending on whether the cell is a normal table data row or part of a table header).

Using Classes

The above examples use inline style sheets to set the CSS properties. This is only because it makes it easier for demonstration purposes. I strongly encourage you to use a CSS class defined in an external style sheet to set your styles. Even embedded style sheets are usually better than inline.

Here’s an example of setting the table’s background color and other properties using a CSS class.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *