/ How to make a background in HTML. Brief instruction

How to make a background in HTML. Brief instruction

This article will allow you to understand the question: "How to make a background in HTML?" The most common and convenient methods that are used by modern developers will be disassembled.

how to make a background in html

To understand how to make a background in HTML, you need onlyonly to study one simple attribute. Namely bgcolor, which can be assigned values ​​in the form of the name of colors or their individual code. You can use this attribute for any tag or element, for example, for individual paragraphs, for a form, a table, etc. To change the color of the entire document, specify the bgcolor attribute for the body tag. But there is one thing: bgcolor has long been recognized as undesirable and makes your code automatically invalid. The consortium of the World Wide Web calls for the use of all the developers of CSS analogs. The language of cascading tables allows you to replace unwanted attributes and even adds new features. It is with the help of CSS that you can achieve the closest result to your plan.

Analogs of attributes

To create a background for a site, it's bestuse the language of cascading style sheets. The background-color property will change the background color of any element. If this command does not have a special purpose for a particular tag, the background will change for the entire document. For example, the entry background-color: red, will make the background of the site red. And if a more detailed description is given, for example p {background-color: green}, then the background of each paragraph tag p becomes green. The more specific things are given, the rule has more priority. You can use a short background entry. As with the bgcolor attribute, you can specify all known color description methods for the background-color property.

  1. By name. There are 17 main names in total (red, green, blue, etc.).
  2. By the hexadecimal value, where it is composed of digits from 0 to 9 and letters from A to F (# c0c0c0).
  3. Using the abbreviations RGB, RGBA, HSL, HSLA. The recording in this way has the following form of RBG (122, 142, 92) or HSL (13, 21%, 75%).

    create a background for the site

Picture

One of the most remarkable features of CSS -it's an opportunity to use background images for a site. In this case, instead of the usual background, a pre-selected picture will be applied. The background-image property can be used for any element or for the entire page, like the background-color command. The url entry is a mandatory value. After it, the address that should refer to the image follows. For example, the entry background-image: url (image / 2.gif), select the file 2.gif from the image directory and make it the background image. The address must be in brackets. This rule can have a short background entry, where you can write any properties related to the background. With the help of additional commands, you can achieve interesting effects. For example, background-attachment tells the browser how to enter the image when scrolling the user's window. A background image can always be in one place or move along with all the contents of a particular element.

background images for the site

Conclusion

We hope that you learned from this article howmake background in html. In this case, the choice is given in several different ways. If it is important for you that your code is valid, you can not use the HMTL bgcolor attribute. And it's best to forget about this command and use only CSS rules. After all, cascading style sheets were invented specifically to make it easier to design the pages. That's why attributes like bgcolor go back in time and are considered undesirable when creating HTML pages. After these words, you can consider the question "how to make the background in HTML" closed.

Liked:
0
Popular Posts
Spiritual development
Food
yup