39

How can I remove the caret from a <input type="text"> element only using CSS and not JavaScript?

Davide Cannizzo
  • 2,826
  • 1
  • 29
  • 31

2 Answers2

43

Of course you can do it just with CSS.

Add this code to your CSS file:

border: none;
color: transparent;
text-shadow: 0 0 0 gray;
text-align: center;

&:focus {
    outline: none;
}

Here you have the SOURCE and a DEMO

Rafa Romero
  • 2,667
  • 5
  • 25
  • 51
8

I can only say you that you can achieve this by applying the color through css :

<input type="text" style="color: transparent;text-shadow: 0 0 0 red;" />

FIDDLE DEMO

Otherwise there is no way to style the text cursor with CSS.

Rakesh Shetty
  • 4,548
  • 7
  • 40
  • 79