Home>Article>Web Front-end> How to set background color in html? Detailed analysis of HTML background color code

How to set background color in html? Detailed analysis of HTML background color code

寻∝梦
寻∝梦 Original
2018-09-11 13:38:33 114882browse

This article usesHTMLcode and CSS style code to show you how to set the background color of HTML. There is also an introduction on how to setbackground imagelater. I hope it will be helpful to everyone, let’s take a look at this article now

First of all, let’s take a look at setting the background color in HTML:

us First, set a background color. Set the background color in the body tag and let's see the effect:

    PHP中文网 
这是PHP中文网

The background color is set to black. Can you think of the effect of displaying it in the browser?

How to set background color in html? Detailed analysis of HTML background color code

Yes, this is the effect. Nothing can be seen. Let’s see if we can set the font to a color and see if it can be displayed:

 

这是PHP中文网

Now let’s take a look at the effect:

How to set background color in html? Detailed analysis of HTML background color code

Is it obvious that adding a color to the font can display the text, but there are still two words that have not been added color, so it still cannot be displayed.

Now let’s take a look at how to create a text background:

 

这是PHP中文网

The font tag no longer works at this time, so we decisively use css styles to change it. Background color, as you can see, this is a simple css style that only sets a background color.

Let’s take a look at the effect displayed in the browser:

How to set background color in html? Detailed analysis of HTML background color code

##Because of the p tag, the background It occupies the entire row. This way the effect looks more obvious, so I won’t frame it. I’ll just teach you the method. When we can’t use so much background, we can add a div tag around the p tag and set the width. is the width of the text, so that the text background will not be displayed in one line. This is also one of the commonly used methods.

Of course, you can also use pictures as background images. Let’s take a look at the effect examples:

    PHP中文网 

这是PHP中文网

This is a picture copied from the Internet, and the effect is still very good Obviously, let’s look at the example now:


How to set background color in html? Detailed analysis of HTML background color code

This is used as the background of the entire web page. We can find good-looking pictures from other places that are suitable for use as background images. We can right-click on that picture, select copy image address, and add it to this URL. This is also very simple. You can practice more below to see if the effect is the same as mine.

This article about setting the background color in HTML ends here. If you want to learn more, go to the PHP Chinese website and learn in the

HTML Learning Manualcolumn. If you have any questions, you can leave a message below.

【Editor's Recommendation】

How to set spaces in HTML paragraph elements? Summary of HTML space settings

#How to use the big tag in html? Usage examples of html big tag

The above is the detailed content of How to set background color in html? Detailed analysis of HTML background color code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn