Styling letters of a word within an input differently, possible?

前端 未结 4 1277
独厮守ぢ
独厮守ぢ 2021-02-06 04:08

Wondering if this is even possible, but if I have a input containing text, for example lets say the word \'Test\' is in the input. What I would like to be able to do is change

4条回答
  •  难免孤独
    2021-02-06 04:32

    No it's not possible with an tag. You can however trick the user into believing he is using a styled input by replacing it with a contendeditable div or something.

    However, I looked into this couple of years ago, and it's a mess if you want a reliable cross browser solution for this. Unless I remembered wrong the html from just showing a bold text in a contenteditable div could easily result in the following across the major browsers:

    Bold 
    Bold 
    Bold 
    Bold 
    Bold 
    

    No kiddin.

提交回复
热议问题