April 4, 2019
How to create a text with a gradient background in html using a div?
We all love those gradients when we want to show a text in the background. With the below simple css snippet, you can create a simple text with a gradient background.
<!DOCTYPE html> <html lang="en"> <head> <title>Hell</title> <style> .gradientbackground { color: white; font-size: 40px; font-family: Arial; text-align: center; background: #21314b; background: linear-gradient(to right, #21314b 0%,#015d6c 50%,#21314b 100%); background: -moz-linear-gradient(left, #21314b 0%, #015d6c 50%, #21314b 100%); background: -webkit-gradient(linear, left top, right top, color-stop(0%,#21314b), color-stop(50%,#015d6c), color-stop(100%,#21314b)); background: -webkit-linear-gradient(left, #21314b 0%,#015d6c 50%,#21314b 100%); background: -o-linear-gradient(left, #21314b 0%,#015d6c 50%,#21314b 100%); background: -ms-linear-gradient(left, #21314b 0%,#015d6c 50%,#21314b 100%); } </style> </head> <body> <div class="gradientbackground">Hello</div> </body> </html>