Setting the background color using Internal CSS
Setting the background color using internal CSS involves defining a style block within the HTML document’s <head> section and specifying the `background-color` property with a color value for the desired elements.
Setting the background color using Internal CSS Syntax:
<style>
/* Internal CSS starts here */
</style>
Setting the background color using Internal CSS Example:
Below is the example that illustrates the use of internal CSS.
HTML
<!DOCTYPE html> < html > < head > < style > body { background-color: powderblue; } h1 { color: green; text-align: center; } h3 { text-align: center; } </ style > </ head > < body > < h1 >w3wiki</ h1 > < h3 > How to change color of Background?(Using Internal CSS) </ h3 > </ body > </ html > |
Output: This will be displayed when html file is opened in browser
Explanation:
- In the above example Internal CSS sets the background to powder blue for the entire page.
- <h1> text is green and center-aligned; <h3> is center-aligned.
- Output displays “w3wiki” in <h1> and “How to change color of Background? (Using Internal CSS)” in <h3>.
Set Background Color using CSS
In CSS, setting the background color involves specifying a color for the background of an element using the CSS `background-color` property. This determines the color displayed behind the content within the element on a webpage.
The background color can be changed in three ways:
Table of Content
- Setting the background color using Inline CSS
- Setting the background color using Internal CSS
- Setting the background color using External CSS