How To Set The Background Color In HTML

natalia

New member
Specify the background color that you want to use. HTML colors are determined by way of code, depending on the tone. You can use W3SCHOOLS HTML's free color selection to find the code (codes) for the color (s) you want to use.
In the computer's web browser https://www.w3schools.com/colors/colors_picker.asp go to the address.
In the "Pick a Color" section, click a basic color you want to use.
Select a tone on the right side of the page.
Note the numeric code to the right of the tone.
Picture titled 2609629 2 2
18
Open the HTML file in your favorite text layout. As of HTML5, the < BGCOLOR > HTML attribute is no longer supported. The background color must be specified using CSS, along with all other style properties of the page.[1]
You can use Notepad++ or notepad on a Windows computer. Mac users can edit with TextEdit or BBEdit.
Picture titled 2609629 3 2
Three
add the title" html " to the file. All of the page's style information (including background color) must be encoded between the<style> < /style> tags:
<!DOCTYPE html>
< html>
<head>
<styling>
</styling>
</head>
< / html>
Four
create a blank purchase between the" style " tags. under the < style> tag and above the < /style> tag, you need to have a line in which you can insert information.
Five
Picture titled 2609629 4 2
Picture titled 2609629 5 2
Under
add the" body " element. type the following code between the < style> < /style> tags:
body {
}
Anything you do to the "body" element in CSS affects the entire page.
Skip this step if you want to apply a transitive color.
Method
Two
Set A Monochrome Background
Picture titled 2609629 6 2
A
Find the "html" title of the document. It should be near the top of the document.
Picture titled 2609629 7 2
Two
add the" background-color "property to the" body " element. Background-color: Type between body brackets. At this stage it is necessary to have the following "body" element:
body {
background color:
}
Only one type of the word "color" works in this link, where you cannot use "color".
Picture titled 2609629 8 3
Three
Add the desired background color to the "background-color" property. To do this, type the numeric code of the selected color next to the "background-color:" element and then place a semicolon. For example, you type the following code to make the background of the page pink:
body {
background-color: # d24dff;
}
Picture titled 2609629 9 2
Four
check out " style." At this point, the title of the HTML document should resemble the following code::
<!DOCTYPE html>
< html>
<head>
<styling>
body {
background-color: # d24dff
}
</styling>
</head>
< / html>
Picture titled 2609629 10 2
Five
Use the" background-color " property to apply background colors to other elements. You can use the "background-color" property to specify the backgrounds of other elements, such as the header and paragraph, as you would in the Body element. For example, to apply a background color to the main title (<h1>) or a paragraph (<p>), type code similar to the following code: [2]
<!DOCTYPE html>
< html>
<head>
<styling>
body {
background-color: # 93B874;
}
h1 {
background-color: # 00b33c;
}
p {
background color: # FFFFFF);
}
</styling>
</head>
<body>
< h1>header with Yesil background < / h1>
< p>paragraph with white background< / p>
</body>
< / html>
Method
Three
Creating A Cascading Background
Picture titled 2609629 11 2
A
Find the "html" title of the document. It should be near the top of the document.
Picture titled 2609629 12 2
Two
Understand the basic word of this process. When creating a transitive color, there are two information needs: the starting point/Open and the colors to switch. You can choose more than one color to switch between them all, and you can choose one direction or open for switching.[3]
background: linear gradient(direction/angle, color1, color2, color3 etc.);
Picture titled 2609629 13 2
Three
Create a vertical transition. If you do not specify a direction, the transition is from top to bottom. Add the following code between the < style> < /style> tags to create your own transition:
html {
min-height: 100%;
}
body {
background: - WebKit-linear-gradient (#93B874, # C9DCB9);
background:-o-linear-gradient (#93B874, # C9DCB9);
background:-moz-linear-gradient (#93B874, # C9DCB9);
background: linear gradient (#93B874, # C9DCB9);
background-color: # 93B874;
}
Different browsers have different migration application functions, so you need to add several different versions of the code.
Picture titled 2609629 14 2
Four
Create a directional pass. If you prefer to create a non-vertical transition, you can add a transition direction to change the color transition's rendering method. To do this, type the following code between the <style></style> tags: [4]
html {
min-height: 100%;
}

body {
background: - WebKit-linear-gradient (left, #93B874, #C9DCB9);
background:-o-linear-gradient (right, #93B874, #C9DCB9);
background:-moz-linear-gradient (right, #93B874, #C9DCB9);
background: linear gradient (right, #93B874, #C9DCB9);
background-color: # 93B874;
}
You can play with the tags" left "and" right " to try different directions in transition.
Picture titled 2609629 15 2
Five
Use other features to adjust the transition. There are many things you can do on transitions.
For example, in addition to adding more than two colors, you can add one face after each color. This allows the setting of how much space each color slice will have. Here's a passage from this princess proper example:
background: linear gradient (#93B874 10%,# C9DCB9 70%, # 000000 90%);
Add transparency to its colors. This allows the color to fade. Use the same color to avoid fading to a different color. You need to use the RGBA () function to specify the color. The end value specifies transparency: 0 for opaque, 1 for transparent.
background: linear gradient (right, rgba (147,184,116,0), rgba (147,184,116,1));
Picture titled 2609629 16 2
Under
Review the completed code. The code for creating a color transition in the background of the Web site is similar to:
<!DOCTYPE html>
< html>
<head>
<styling>
html {
min-height: 100%;
}

body {
background: - WebKit-linear-gradient (left, #93B874, #C9DCB9);
background:-o-linear-gradient (right, #93B874, #C9DCB9);
background:-moz-linear-gradient (right, #93B874, #C9DCB9);
background: linear gradient (right, #93B874, #C9DCB9);
background-color: # 93B874;
}
</styling>
</head>
<body>
</body>
< / html>
Method
Four
Creating A Changing Background
Picture titled 2609629 17 2
A
Find the "html" title of the document. It should be near the top of the document.
Picture titled 2609629 18 2
Two
add the animation property to the" body " element. type the following code below the"body {"parenthesis and above the closing parenthesis: [5]
- webkit-animation: colorchange 60s infinite;
animation: colorchange 60s infinite;
The top line is written for Chromium-based browsers, while the bottom line is for other browsers.
Picture titled 2609629 19 2
Three
Add your colors to the animation. You will use the @ keyframes rule to determine the background colors that will be migrated at this stage and how long they will remain on each color page. For different scanners, they will enter differently again. Enter the code versions below the closed" body " parenthesis: [6]
@ - webkit-keyframes colorchange {
0% {background: # 33FFF3;}
25% {background: # 78281F;}
50% {background: # 117A65;}
75% {background: # DC7633;}
100% {background: #9b59b6;}
}
@ keyframes colorchange {
0% {background: # 33FFF3;}
25% {background: # 78281F;}
50% {background: # 117A65;}
75% {background: # DC7633;}
100% {background: #9b59b6;}
}
 
Top