Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS color vs. background-color vs. background?

Tags:

html

css

In HTML when do I use color, and what is the difference between background-color and also the background tag?

What are the differences?

like image 932
Doggo Avatar asked Aug 19 '16 07:08

Doggo


People also ask

What is color and background color?

Description. The Background Color information is stored for image and photo files that have a color specified for the image background. The background color is, in most cases, displayed in the form of an RGB triplet or a hexadecimal code.

What is difference between bgcolor and color?

Bg stands for background. +2 The main difference is that bgcolor is an attribute used in the HTML document while background-color is a CSS property, used inside a declarations block within a CSS rule.

What is the CSS code for background color?

Background-color values can be expressed in hexadecimal values such as #FFFFFF, #000000, and #FF0000. Background-color values can be expressed using rgb such as rgb(255,255,255), rgb(0,0,0), and rgb(255,0,0).

What is the basic difference between back ground color and background image?

The bgcolor attribute is used for coloring the background of the document while background attribute specifies a background image for a document.


2 Answers

color is referring to the text color in that element.

background-color refers to the background color

background is shorthand to combine many background tags into one line.

background: #ffffff url("img_tree.png") no-repeat right top; 

Combines color, image and background image properties in the one line instead of typing our each style individually.

w3schools

like image 145
MomasVII Avatar answered Sep 29 '22 08:09

MomasVII


I will give you a example using this html element:

<span class="value"> This is my text </span>

.value { color: red, background-color: black}

The CSS color is used to change the text color of a html element. In this example "This is my text" would be red. The CSS background-color is used to change the background color so in this case you would get a black box with red text inside it. Finally the background is used to set all the background properties in one declaration. For example:

background: #00ff00 url("smiley.gif") no-repeat fixed center;

This changes the background color, adds the image "smiley.gif" to the background and it centers the image, it doesnt repeat the image if it has the space.

like image 42
Juan Pablo Avatar answered Sep 29 '22 09:09

Juan Pablo