- Sometime for some requirement to website design ,you will need to set a character, word, or an entire sentence with half-style. For that you will need to use some css or JavaScript.
- Let’s Learn How to do with css it below.
- Here I will show you in 4 different method of how to set a character, word, or an entire sentence with half-style.
Transparent half-style
<!DOCTYPE html> <html> <head> <style> .demo {float: left;width: 100%;text-align: center;background:#f2f2f2;} h1 {display: inline-block; margin: 0; line-height: 1em; font-family: Helvetica, Arial, sans-serif;font-weight: bold;font-size: 200px; background: linear-gradient(to right, #b9557b 50%, transparent 50%);background-clip: text; -webkit-background-clip: text;-webkit-text-fill-color: transparent; } </style> </head> <body> <div class="demo"> <h1>X</h1> </div> </body> </html>
Output:
Character with half-style
<!DOCTYPE html> <html> <head> <style> .demo {float: left;width: 100%;text-align: center;background:#f2f2f2;} h1 {display: inline-block;margin: 0;line-height: 1em; font-family: Helvetica, Arial, sans-serif;font-weight: bold;font-size: 200px;background: linear-gradient(to right, #b9557b 50%, #1c43a0 50%);background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;} </style> </head> <body> <div class="demo"> <h1>X</h1> </div> </body> </html>
Output :
Full Word Style
<!DOCTYPE html> <html> <head> <style> .demo {float: left;width: 100%;text-align: center;background:#f2f2f2;} span {display: inline-block;margin: 0;line-height: 1em; font-family: Helvetica, Arial, sans-serif;font-weight: bold;font-size: 60px;background: linear-gradient(to right, #1c43a0 50%,#b9557b 50%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;} </style> </head> <body> <div class="demo"> <div> <span>T</span> <span>E</span> <span>X</span> <span>T</span> </div> </div> </body> </html>
Output :
Horizontally half-styled letter
<!DOCTYPE html> <html> <head> <style> .demo {float: left;width: 100%;text-align: center;background:#f2f2f2;} .horizontal {display: inline-block;margin: 0;line-height: 1em; font-family: Helvetica, Arial, sans-serif;font-weight: bold;font-size: 60px;background: linear-gradient(to top, #1c43a0 50%,#b9557b 50%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;} </style> </head> <body> <div class="demo"><div> <span class="horizontal">X</span> </div> </div> </body> </html>
Output :
Thank You 🙂