How to Add Background Color in Input and Text Fields using CSS ? Last Updated : 07 Feb, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will explore different approaches to adding background color to input and text fields using CSS. Customizing the appearance of input and text fields is an essential aspect of web design, and changing the background color is a powerful way to enhance the visual appeal of these elements. Method 1: Basic CSS StylingThe basic method is used to add a background color to input and text fields is by using the background-color property in CSS. Example: HTML <!DOCTYPE html> <html lang="en"> <head> <title> How to Add Background Color in Input and Text Fields Using CSS? </title> <style> input, textarea { background-color: green; } </style> </head> <body> <form> <label for="name"> Name: </label> <input type="text" id="name" name="name" required><br><br> <label for="email"> Email Id: </label> <input type="email" id="email" name="email" required><br><br> <label for="email"> Comment: </label> <textarea id="email" name="email"></textarea><br><br> <button type="submit">Submit</button> </form> </body> </html> Output: Method 2: Add Background on Hover EffectTo create an interactive experience, you can add a different background color when the user hovers over the input or text field. Utilize the :hover pseudo-class for this effect. Example: HTML <!DOCTYPE html> <html lang="en"> <head> <title> How to Add Background Color in Input and Text Fields Using CSS? </title> <style> input:hover, textarea:hover { background-color: green; } </style> </head> <body> <form> <label for="name"> Name: </label> <input type="text" id="name" name="name" required><br><br> <label for="email"> Email Id: </label> <input type="email" id="email" name="email" required><br><br> <label for="email"> Comment: </label> <textarea id="email" name="email"></textarea><br><br> <button type="submit">Submit</button> </form> </body> </html> Output: Method 3: Add Gradient BackgroundFor a more sophisticated look, you can use gradients as background colors. This example creates a gradient background for input and text fields. Example: HTML <!DOCTYPE html> <html lang="en"> <head> <title> How to Add Background Color in Input and Text Fields Using CSS? </title> <style> input, textarea { background: linear-gradient(to right, #121de9, #016c31); } </style> </head> <body> <form> <label for="name"> Name: </label> <input type="text" id="name" name="name" required><br><br> <label for="email"> Email Id: </label> <input type="email" id="email" name="email" required><br><br> <label for="email"> Comment: </label> <textarea id="email" name="email"></textarea><br><br> <button type="submit">Submit</button> </form> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Add Background Color in Input and Text Fields using CSS ? V vkash8574 Follow Improve Article Tags : Web Technologies CSS Geeks Premier League CSS-Questions Geeks Premier League 2023 +1 More Similar Reads How to Add Image in Text Background using HTML and CSS ? In this article, we will use HTML and CSS to set the image in the text background. To set the image in the text background, some CSS property is used. To add an image in the text background using HTML and CSS, create a container element (e.g., a `<div>`), set its background to the desired imag 2 min read How to set background color for an elements using jQuery ? In this article, we will set the background color for an element using jQuery. To add the background color, we use css() method. The css() method in JQuery is used to change style property of the selected element. The css() in JQuery can be used in different ways. The css() method can be used to che 1 min read How to Change the Background Color of Table using CSS? Changing the background color of a table using CSS can help improve the visual appearance of a website or web application. we will learn how to change the background color of the table using CSS with different approaches.These are the following approaches:Table of Content Using Inline CSSUsing Inter 2 min read How to apply bottom border with only Input text field using CSS ? Adding a bottom border to the input field visually distinguishes it from surrounding elements on the page. Making input fields stand out on a website in a form for example is crucial. Styling these inputs with clear borders, appealing colors, and effects, can easily capture the userâs attention.Tabl 3 min read How to add a specific color to an element using CSS ? In this article, we will discuss elements and how to add a specific color to an element using CSS properties. Basically, the HTML element is the collection of start and end tags with the content inserted in between them. Elements can be nested. <tagname> Content </tagname> Note: Please r 2 min read How to add Background-Color for Text Width Instead of Entire Element Width using CSS ? In this article, we will see how to add background color for the text width instead of the entire element width using CSS. The display: inline or display: inline-block property is used to set the background color of the text width. Syntax: display: inline; display: inline-block; Approach: We will cr 2 min read How to set Input Fields with Black Border on Focus using CSS ? The visual cues play a crucial role in guiding user interaction in web design. One common interaction is when users focus on input fields, such as text boxes or text areas, during form filling. To enhance the user experience, it's essential to provide clear feedback when an input field is in focus. 2 min read How to change the font-color of disabled input using CSS ? In this article, we are going to learn how to change the font-color of disabled input. There is a method to solve this problem, which is discussed below: Approach: With adding basic CSS property we are able to change the font-color of a disabled input. The disabled input element is unusable and un-c 2 min read How to Set the background-color of different Elements in CSS? Background colors in CSS set the color behind an element's content and padding. Use the background-color property to assign colors to elements, specifying values in hex, RGB, or color names. This allows customization of elements' backgrounds for design and readability.Using Background Color Property 2 min read Set Background Color using CSS Setting the background color in CSS involves using the background-color property to define the color displayed behind the content within an HTML element. This can be achieved through three primary methods: inline CSS, internal CSS, and external CSS. Each method offers different advantages depending 4 min read Like