You are viewing the article How to Set Background Color in HTML at Thptlaihoa.edu.vn you can quickly access the necessary information in the table of contents of the article below.
HTML allows web developers to customize the appearance of their websites in various ways, and one of the simplest yet impactful techniques is setting the background color. This seemingly minor adjustment can drastically enhance the overall aesthetic and visual appeal of a website. Whether it’s a vibrant, eye-catching hue or a serene, subtle shade, the background color plays a crucial role in defining the website’s personality and creating a harmonious user experience. In this guide, we will explore the different methods and options available to set the background color in HTML, enabling developers to effortlessly create stunning and engaging web pages.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 77,680 times.
This is an article on how to change the background color of the web page by editing the HTML file.
Steps
Prepare Before Editing HTML
- Go to https://www.w3schops.com/cpors/cpors_picker.asp using your computer’s web browser.
- Click the base color you want to use in the “Pick a Cpor” section.
- Select a color tone on the right side of the page.
- Record the code shown to the right of that tone.
- You can use Notepad++ or Notepad on a Windows computer, or use TextEdit or BBEdit on a Mac computer.
<style></style>
tag:
<!DOCTYPEhtml><html><head><style></style></head></html>
<style>
tag and above the </style>
tag. <style></style>
tag:
- Changes to the “body” part of the CSS will affect the entire page.
- Skip this step if you want to create a gradient background.
body{}
Create a solid color background
background-cpor:
in the brackets of the page body. You should now have a “body” section like this:
- Here you can only type “cpor” because typing “cpour” will fail.
body{background-cpor:}
body{background-cpor:#d24dff;}
<!DOCTYPEhtml><html><head><style>body{background-cpor:#d24dff}</style></head></html>
<!DOCTYPEhtml><html><head><style>body{background-cpor:#93B874;}h1{background-cpor:#00b33c;}p{background-cpor:#FFFFFF);}</style></head><body><h1>Greenheading</h1><p>Whiteparagraph</p></body></html>
Create gradient color background
background:linear-gradient(direction/angle,cpor1,cpor2,cpor3,etc.);
<style></style>
tag:
- Each browser has a different way of displaying gradient color functionality, so you need to add more styles of commands.
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-cpor:#93B874;}
<style></style>
tag: [4] XResearch Source
- You can use the “left” (left) and “right” (right) tags to try out gradients in a different direction.
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(toright,#93B874,#C9DCB9);background-cpor:#93B874;}
- For example, you can not only add more than two colors, but you can also set a percentage for each color. This is how you create the area for each color section. Here is an example of a color gradient made according to this principle:
background:linear-gradient(#93B87410%,#C9DCB970%,#00000090%);
background:linear-gradient(toright,rgba(147,184,116,0),rgba(147,184,116,1));
<!DOCTYPEhtml><html><head><style>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(toright,#93B874,#C9DCB9);background-cpor:#93B874;}</style></head><body></body></html>____
Create background automatically change color
- The first line of the code is for open source browsers, and the last line of the code is for other browsers.
-webkit-animation:cporchange60sinfinite;animation:cporchange60sinfinite;
- Note, the two rules ( @-webkit-keyframes and @keyframes have the same background color and percentage. You need to match these two to create the same experience across all browsers.
- The percentages ( 0% , 25% , etc.) are calculated according to the total motion time ( 60s ). When you load the page, the solid background color ( #33FFF3 ) is set at 0% . After 25% of the 60 seconds are up, the background will change to #7821F and so on.
- You can adjust the time and color to produce the desired result.
@-webkit-keyframescporchange{0%{background:#33FFF3;}25%{background:#78281F;}50%{background:#117A65;}75%{background:#DC7633;}100%{background:#9B59B6;}}@keyframescporchange{0%{background:#33FFF3;}25%{background:#78281F;}50%{background:#117A65;}75%{background:#DC7633;}100%{background:#9B59B6;}}
<!DOCTYPEhtml><html><head><style>body{-webkit-animation:cporchange60sinfinite;animation:cporchange60sinfinite;}@-webkit-keyframescporchange{0%{background:#33FFF3;}25%{background:#78281F;}50%{background:#117A65;}75%{background:#DC7633;}100%{background:# 9B59B6;}}@keyframescporchange{0%{background:#33FFF3;}25%{background:#78281F;}50%{background:#117A65;}75%{background:#DC7633;}100%{background:# 9B59B6;}}</style></head><body></body></html>___
Advice
- If you want to use a base color in your HTML code, you can enter the color name without adding the pound sign (#) instead of using the HTML color code. For example, to make the background orange, you would type
background-cpor: orange;
here. - You can also use an image as the background of your web page using HTML.
Warning
- Test any changes to your website before applying online.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This article has been viewed 77,680 times.
This is an article on how to change the background color of the web page by editing the HTML file.
In conclusion, setting the background color in HTML is a simple yet effective way to customize the overall look and feel of a web page. By using the “background-color” property in CSS, developers can choose from a wide range of colors to create the desired aesthetic. This feature allows for greater flexibility and creativity in web design, as it enables the customization of not only the content but also the background. It is important, however, to ensure that the chosen background color does not hamper readability or accessibility of the content. By following the guidelines and best practices in color selection, developers can create visually appealing and user-friendly websites. Overall, setting the background color in HTML is a crucial element in web design that enhances the overall user experience.
Thank you for reading this post How to Set Background Color in HTML at Thptlaihoa.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search:
1. “HTML code to set background color”
2. “Inline CSS to set background color in HTML”
3. “CSS styles for setting background color”
4. “HTML background color attribute”
5. “Setting background color in HTML with hexadecimal color codes”
6. “Changing background color using CSS classes in HTML”
7. “HTML code to set background color with RGB values”
8. “How to use CSS gradients for background color in HTML”
9. “Setting background color for different elements in HTML”
10. “Background color options in HTML5”