Created
October 2, 2012 12:31
-
-
Save cameronhunter/3818664 to your computer and use it in GitHub Desktop.
Responsive abbreviations in HTML using CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Responsive Abbreviations</title> | |
<style type="text/css"> | |
/* Show "U.K." */ | |
abbr {cursor:default; border:none;} | |
/* Show "United Kingdom" */ | |
@media (min-width: 481px) { | |
abbr span {display:none;} | |
abbr:before {content: attr(title);} | |
} | |
/* Show "United Kingdom (U.K.)" */ | |
@media (min-width: 1024px) { | |
abbr span {display:inline;} | |
abbr span:before {content: ' (';} | |
abbr:before {content: attr(title);} | |
abbr:after {content: ')';} | |
} | |
</style> | |
</head> | |
<body> | |
This is a sentence talking about the <abbr title="United Kingdom"><span>U.K.</span></abbr> and the role they play in <abbr title="North American Treaty Organisation"><span>NATO</span></abbr>. | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment