How to Remove the Blinking Cursor from an Input Element

Remove Blinking Cursor From Input Field

Here is a real quick fix for that annoying blinking cursor in an input field. This is a very bad practice for accessability, and should be thought about before use.

HTML

<input type="text" name="" class="input">

CSS

.input{
    color: transparent;
    text-shadow: 0 0 0 red;
}

.input:focus{
    outline: none;
}

Step by Step

HTML Structure

  • Create an input element and assign it a class for styling purposes.

CSS Styles

  • Use the color: transparent; property to make the input text invisible.
  • Apply text-shadow: 0 0 0 red; to display the text shadow instead of the text itself. Change the color to your desired color.
  • Add outline: none; in the :focus pseudo-class to remove the outline when the input is focused.

Customizing the Text Color

Want to change the text color? Simply update the text-shadow color in the CSS. For example, to make the text blue, you would use:

text-shadow: 0 0 0 blue;

Accessibility Note

Removing the blinking cursor can hinder accessibility, making it harder for users to know where they are typing. Consider the user experience and accessibility implications before implementing this fix.

Conclusion

And there you have it! A super simple way to remove the blinking cursor from your input fields. Use this trick wisely, and always keep accessibility in mind. Got any questions or alternative methods? Drop them in the comments below!

about raymond ware

About Me

Hi, I am Full Stack Developer. I am passionate about JavaScript, and find myself working on a lot of React based projects.

Raymond Ware logo
©2020 Made from scratch by Raymond Ware