- Home
- About
- Conversations
- Tips
- Amazon MP3: DRM-free music
- iTunes Plus tips!
- Ogg in iTunes
- Show hidden files (.htaccess) in OS X
- Convert FLAC to MP3, WAV, or AIFF to play in iTunes on Mac OS X
- Convert WMA to MP3
- Swap left Alt and Ctrl keys in Windows
- Boot Camp: Delete, Right-Click, Middle-Click
- Creating nice aliases
- CSS generated content special characters
- Default Application in OS X
- Enso (Windows Quicksilver)
- Import Gmail contacts to Mail
- Install RAM: MacBook Pro
- iPhoto: Deleting aliased pictures
- Using Keyboards with Your Mac + the Microsoft Natural 4000
- Aurora - iTunes Alarm Clock
- Delete keys on Macs
- Projects
- Boost and XCode
- Code
- Contact
- create content
Special characters in CSS generated content (::before, ::after)
Submitted by alanhogan on December 10, 2005 - 6:00pm.
Tip | Code | Web Design | CSS | Pseudo-elements | Unicode | W3C
If you do CSS, you may be familiar with the ::before pseudo-element. Have you ever tried using it to insert an unusual character? I did today, and it took about 20 minutes to figure it out. Here’s here to do it.
"See, you can’t use an HTML/XHTML entity like this, because it actually inserts the ampersand and all:
#metaInfo::before {
content: "⇓";
display: inline;
}
Turns out you have to put in an escaped reference to the hexadecimal Unicode character value.
#metaInfo::before {
content: "\21D3"; /*Hexadecimal for Unicode down arrow (⇓)*/
display: inline;
}
The fact you cannot use HTML entities in generated content does not seem to be spelled out in the W3C specs, though it is hinted at in the section on generated content.
(FYI: Some people use :before instead of ::before. While the W3C may have been ambiguous about this type of thing in the past, it is now understood that :foo represents a pseudo-class and ::foo represents a pseudo-element.
Page Outdated! Comments disabled!
As do many people using Drupal to power their website, I get a lot of comment spam, and Drupal's spam filter is horrible! So I have permanently disabled comments on old.alanhogan.com. Try the new version of this page (which may not exist, but should if this page actually has content besides a list of other articles).
Consider using my contact form to get in touch. And remember that AlanHogan.com is live and old.alanhogan.com is here as a backup only, and a stopgap measure because some AlanHogan.com functionality is not implemented yet.
Sponsored by
To advertise here, contact me.



