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

Как изменить цвет фона в html

  • автор:

Как изменить цвет фона в html

In this article, we will see how to set the background color of an element. The purpose of using style attribute is to add styles to the elements. Using style attribute with different elements results in change in that element only. This attribute can be used as inline, internal or external. The style attribute provides number of properties which can be used to improve a simple html page.

The background color can be changed in three ways:

  • Inline style attribute
  • Internal CSS
  • External CSS

The HTML5 doesn’t support the ‘bgcolor’ attribute of <body> tag, therefore we need to use the inline style attribute and internal CSS options for changing the color of a web page. For internal CSS add <style> tag at beginning of html file and add the tag to which the changes are being applied in this case the <body> tag is used.

Syntax:

Example 1: Below is the example that illustrates the use of inline CSS.

How to Add & Change Background Color in HTML

Anna Fitzgerald

Setting the background color of a web page or an element on the page can enable you to create unique layouts.

Person adding and changing the background color of a website in html

Take the homepage of Delish as an example. The background image of its header section is a colorful soup. To ensure readers can still see the name of the recipe, the background color of the text box is set to white. The effect is striking and easy to read.

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

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