Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to set the background for html

Shulou Source: shulou.com Published: 2022-05-31 13:14:49 09月24日 Update

This article introduces the knowledge of "how to set the background for html". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Html setting background method: 1, use the bgcolor attribute of the body tag to set the background color; 2, use the background attribute of the body tag to set the background picture; 3, use the style attribute in the body tag to add "background: color value / url ('picture path')".

The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.

Html sets the background

1. The bgcolor attribute of the body tag

The bgcolor property specifies the background color of the document.

Hello world!

Effect picture:

Note: if you use a color name, different browsers will have different rendering structures, and if you use RGB code, Firefox will not be able to display the correct color.

Tip: if all browsers want to display the same color, use a hexadecimal color code.

2. The background attribute of the body tag

The background attribute specifies the background image of the document.

Effect picture:

3. Css background attribute

The background property is an abbreviated property that sets all the background properties in a declaration.

The properties that can be set are:

Background-color

Background-position

Background-size

Background-repeat

Background-origin

Background-clip

Background-attachment

Background-image

Example:

Body {background: pink url ('smiley.gif') no-repeat fixed center;}

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

This is some text

Effect picture:

This is the end of "how to set the background for html". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Properties background colors labels effects renderings browsers code content pictures documents more knowledge different practical same successful learning and then hexadecimal Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Shulou Tech Info Redmi MySQL