You can use the css-property content
and attr
to display the content of an attribute in an :after
pseudo element. You could either use the default title attribute (which is a semantic solution), or create a custom attribute, e.g. data-title
.
HTML:
<label for="male" data-title="Please, refer to Wikipedia!">Male</label>
CSS:
label[data-title]{
position: relative;
&:hover:after{
font-size: 1rem;
font-weight: normal;
display: block;
position: absolute;
left: -8em;
bottom: 2em;
content: attr(data-title);
background-color: white;
width: 20em;
text-aling: center;
}
}