HTML Code for Gray

Introduction to HTML Code for Gray

When designing a website or web application, it's important to have control over the visual appearance of elements. One way to achieve this is by using HTML to specify the color of text, backgrounds, borders, and other elements. In this blog post, we will explore how to use HTML code to create gray-colored elements on a web page.

Using Hexadecimal Code for Gray

In HTML, colors can be specified using hexadecimal codes. The hexadecimal code for gray is #808080. This code represents an equal mixture of red, green, and blue. To apply this color to an element, you can use the style attribute within an HTML tag, like this: <p style='color: #808080;'>This text is gray</p>

Using RGB Code for Gray

Another way to specify the gray color in HTML is by using RGB values. The RGB values for gray are (128, 128, 128), representing equal amounts of red, green, and blue. This can be applied to an element using the style attribute as well, like this: <div style='background-color: rgb(128, 128, 128);'>This background is gray</div>

Using HTML Code Example

<pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Gray Color Example&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 style='color: #808080'&gt;This heading is gray&lt;/h1&gt; &lt;p style='background-color: rgb(128, 128, 128)'&gt;This paragraph has a gray background&lt;/p&gt; &lt;/body&gt; &lt;/html&gt;</code></pre>

Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free