top of page
Writer's pictureWeb Coding

How to create a gradient border

Today I will be teaching you how to add a gradient border around your text 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>
 <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
            Vestibulum arcu tellus, 
            ultricies sed erat id, ultricies finibus dui. Proin et 
            tortor nec purus suscipit 
            dignissim. Quisque libero felis, placerat non lorem 
            eget, condimentum consequat 
            elit. Nunc placerat ex malesuada eros sollicitudin 
            vulputate. Proin in orci libero.
             Sed a odio quis turpis finibus mollis quis ut tellus.
              Maecenas vitae ipsum sed
            massa tempus euismod. Mauris ut odio commodo, tempus 
            sapien vitae, pellentesque
            sapien. Aliquam sed ornare ex. Aliquam aliquet luctus 
            nibh pellentesque imperdiet.
            Phasellus eleifend sit amet lorem tincidunt vulputate. 
            Nam ornare tortor vitae
            justo bibendum ullamcorper.
 
 </p>
 </div>
</body>
</html>

CSS

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

div{
 displayflex;
 align-itemscenter;
 justify-contentcenter;
 height30vh;
 width30vh;
 backgroundlinear-gradient( to right#ee0979#ff6a00);
}

p{
 height92%;
 width92%;
 background-color#202020;
 colorwhite;
 overflowhidden;
 text-alignjustify;
 font-size16px;
 padding2%;
}

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

51 views

Comments


bottom of page