How can I capitalize the first letter of each word using CSS I tried also other stake overflow questions but didn't work?

Viewed 113

I need help to capitalize my every First letter of each word but don't know-how I tried following but didn't work:- How can I capitalize the first letter of each word in CSS?

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
    <style>
       h1 {
          text-transform: lowercase;
          display: inline-block;
       }
       h1:first-letter {
           text-transform: uppercase
       }
   </style>
</head>
<body>
    <h1>THIS IS TEST</h1>
</body>
</html>

but it result:- This is test

it only capitalizes T but I need I and T also...

please don't give a solution for JS

1 Answers

You need to use text-transform capitalize

   text-transform:capitalize;

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
    <style>
       h1 {
          text-transform:capitalize;
          display: inline-block;
       }
      
   </style>
</head>
<body>
    <h1>this is test</h1>
</body>
</html

Related