How Do You Set the Background Color of an HTML Element?


Quick Answer

Set the background color of an HTML element using a cascading stylesheet to assign the color to the desired element. Accomplish this by adding the code "background-color: yellow;" inside curly brackets after the correct element. Examples of elements that you can define include body, paragraph (p) and header (h1).

Continue Reading
Related Videos

Full Answer

Cascading stylesheets, or CSS, allow webmasters to change any aspect of their website's appearance. While CSS does not support website framework and requires an existing website build, it is an effective way to fully customize the appearance of a website. CSS is visible on Web browsers running 1.0 versions of Firefox, Safari or Chome, the 4.0 version of Internet Explorer and the 3.5 version of Opera, as of 2015.

Other elements that are customizable include borders, text, columns, cursors, table heights and many more. Borders can have a specified image fill, background color, width, height or radius. These can be specified for the right, left and middle borders of a given area or for the entire bordered area. Similarly, fonts can specify family, color, size, adjusted size or weight.

In addition to specifying color names such as "yellow," you can specify hex codes such as "#00ff00" or RGB color wheel parameters such as "rgb(255,0,255)." Alternately, users can add a background image to an element of the page by specifying the web URL as a "background-image:" instead of a background color.

Learn more about Internet & Networking

Related Questions