An alternative approach to using the title
attribute with the input
element is to utilize HTML5 data
attributes. Below is an example of a tooltip created using the data
attribute along with pure CSS. It's worth mentioning that input[type="text"]
elements do not support the :after
or :before
pseudo-elements.
Take a look at the demonstration first: DEMO
HTML Code
<p>
<label for="id" datatip="Hi I am ToolTip">Name:</label>
<input type="text" value="" />
</p>
CSS Code
p{position:relative; display:inline-block; width:50%;}
label:after
{
content: "?";
position:absolute;
right:-20px;
background:gold;
color:red;
width:18px;
height:18px;
font-size:.9em;
text-align:center;
border-radius:50%;
transition: all .3s;
border:1px solid red;
margin:0 0 0 10px;
}
label:hover:before
{
content:attr(datatip);
position:absolute;
z-index:0;
right:-230px;
top:-100px;
top:0;
transition: all .3s;
width:200px;
border:1px solid red;
}
input{width:200px;}