top of page
Writer's pictureWeb Coding

How to add a gradient border to a text input

Learn how to add a gradient border to a text input using only HTML and CSS


HTML

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <link rel="stylesheet" href="style.css">
</head>
<body>
 <div id="grad">
 <input type="text" placeholder="First Name">
 </div>
</body>
</html>

CSS

body{
 min-height100vh;
 displayflex;
 align-itemscenter;
 justify-contentcenter;
 background-color#1f1f1f;
}

#grad{
 backgroundlinear-gradient(to right#11998e#38ef7d);
 height10vh;
 border-radius32px;
 displayflex;
 justify-contentcenter;
 align-itemscenter;
}

input{
 padding-left7%;
 height85%;
 width90%;
 font-size28px;
 border-radius32px;
 outlinenone;
 bordernone;
}

If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on


YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ

Instagram: https://www.instagram.com/coding_for_the_web/

Twitter: https://twitter.com/LearnWebCoding

13 views

Comments


bottom of page