The Data Attribute

Retrieve Value of the Custom Attribute

It can also even be used in your CSS, like for this silly and lame CSS text changing example.

<!DOCTYPE html>

<html lang="en">
   <meta charset="utf-8">
   <title>Sort of Lame CSS Text Changing</title>

h1 { position: relative; }
h1:hover { color: transparent; }

h1:hover:after {
	content: attr(data-hover-response);
	color: black;
	position: absolute;
	left: 0;


<h1 data-hover-response="I Said Don't Touch Me!"> Don't Touch Me  </h1>


The Data Attribute The Data Attribute Reviewed by Bhaumik Patel on 7:10 AM Rating: 5