How to create Underline Input Text Field using CSS ? Last Updated : 07 Feb, 2024 Comments Improve Suggest changes Like Article Like Report Input Text Field can be underlined by implementing different approaches to applying a bottom border to an input text field, using various methods such as HTML and CSS. Styling input text fields is a crucial aspect of web development, and adding a bottom border is a common way to enhance the visual appeal of these elements. Table of Content Using CSS border-bottom PropertyUsing CSS border-bottom Property with Pseudo-elementsUnderstanding the text-decoration PropertyUsing CSS border-bottom PropertyThe simplest way to add a bottom-border to an input text field is by using CSS. You can achieve this effect with the border-bottom property. Example: HTML <!DOCTYPE html> <html lang="en"> <head> <title> How to Apply Bottom Border to Input Text Field? </title> <style> body { text-align: center; } input { border: none; border-bottom: 5px solid green; } </style> </head> <body> <form> <label for="password"> Password: </label> <input type="password" id="password" name="password" required> <button type="submit">Submit</button> </form> </body> </html> Output: Using CSS border-bottom Property with Pseudo-elementsYou can use pseudo-elements to target specific parts of an element and style them accordingly. Here, we'll use the ::after pseudo-element to create a bottom border. Example: HTML <!DOCTYPE html> <html lang="en"> <head> <title> How to Apply Bottom Border to Input Text Field? </title> <style> body { text-align: center; } input:hover { border: none; border-bottom: 5px solid green; } </style> </head> <body> <form> <label for="password"> Password: </label> <input type="password" id="password" name="password" required> <button type="submit">Submit</button> </form> </body> </html> Output: Understanding the text-decoration PropertyThe text-decoration property in CSS is used to set or remove decorations from text. In this case, we'll use it to create an underline for an input text field. HTML <!DOCTYPE html> <html lang="en"> <head> <title>Underlined Input Field</title> <style> body { text-align: center; } input#password { border: none; outline: none; padding: 5px; font-size: 16px; border-bottom: 5px solid green; } </style> </head> <body> <form> <label for="password"> Password: </label> <input type="password" id="password" name="password" required> <button type="submit">Submit</button> </form> </body> </html> Output: Comment More infoAdvertise with us Next Article How to create Underline Input Text Field 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 Underline Text using CSS? To underline a text using CSS, the CSS text-decoration property is used with the value set to underline.Using text-decorationWe use the text-decoration CSS property to underline a text using CSS. The text that is to be underlined is inserted in a <p> tag and the property is applied.Syntaxtext- 1 min read How to Set the Gap Between Text and Underlining using CSS? The gap between text and underlining is the space you can create between the text and underline, making it text easier to read and look better. Using text-underline-offset PropertyTo set the gap between text and its underline in CSS, use the text-underline-offset property. This property defines the 1 min read How to add underline to canvas-type text using Fabric.js ? Enhancing text presentation on web canvases using Fabric.js involves various techniques, such as adding underlines for improved visual clarity and emphasis. These methods enable developers to customize text elements effectively, contributing to enhanced user experience and design flexibility in web 2 min read How to remove underline from a:before using CSS ? The a:before is used to create an element before the content of the anchor tag and it displays underlined a:before part by default. To remove the underline from a:before using the text-decoration property of CSS and set element display to inline-block. Syntax: text-decoration:none; display:inline-bl 2 min read How to change the underline color in CSS? In this article, we are going to learn how to change the underline color in CSS, To change the underline color in CSS, use the text-decoration-color property. Set it to the desired color value. Styling is implemented in HTML text to make it catchy and attractive. The text can be made italic, underli 1 min read Like