ComputersProgramming

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.

To understand how to make a background in HTML, you just need to study one simple attribute. Namely bgcolor, which can be assigned values as 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 the 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 best to use the language of cascading style sheets. The background-color property will help to change the background color of any element. If this command does not have a special purpose for a particular tag, then 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 you specify a more detailed description, 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 as the value of the background-color property.

  1. By name. There are 17 main names in total (red, green, blue, etc.).
  2. 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%).

Picture

One of the most remarkable features of CSS is the ability 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 the 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 down 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 the image should behave when the user window is scrolled. A background image can always be in one place or move along with all the content of a specific element.

Conclusion

We hope you learned from this article how to make a background in HTML. In this case, the choice is given in several different ways. If you want your code to be 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 such as bgcolor go into the past and are considered undesirable when creating HTML pages. After these words, you can consider the question "how to make the background in HTML" closed.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.atomiyme.com. Theme powered by WordPress.