Skip to content

Instantly share code, notes, and snippets.

@mrwweb
Created June 9, 2014 14:33
Show Gist options
  • Save mrwweb/4010d08929fab1b175f5 to your computer and use it in GitHub Desktop.
Save mrwweb/4010d08929fab1b175f5 to your computer and use it in GitHub Desktop.
CSS to automatically add a filetype to the end of a link. (e.g. "[PDF]") This is a best practice for accessibility and usability. Add or remove types as you see fit.
/* ID Link Mimetypes for Common Filetypes */
a[href$=".doc"]::after {
content: " [DOC]";
}
a[href$=".docx"]::after {
content: " [DOCX]";
}
a[href$=".rtf"]::after {
content: " [RTF]";
}
a[href$=".pdf"]::after {
content: " [PDF]";
}
a[href$=".xls"]::after {
content: " [XLS]";
}
a[href$=".xlsx"]::after {
content: " [XLSX]";
}
a[href$=".csv"]::after {
content: " [CSV]";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment