4 ms·
Wow, for a "three things you need to know" title, this article was surprisingly informative. Combining attr with :before is a nice trick; I'll be on the lookout
by pjungwir 14y ago
Wow, for a "three things you need to know" title, this article was surprisingly informative. Combining attr with :before is a nice trick; I'll be on the lookout for my own reasons to use that. And calc sounds great.
- Igalze 14y agoMy thoughts exactly. I will defiantly consider it formy "Top 10 blogs about 3 thing you need to know (Best)" blog :)
- glitchdout 14y agoHere's a reason to use the :before + attr() combo: Combine it with media queries to progressively display more flair content when more space is available. Check this CSS Tricks article to see what I mean: http://css-tricks.com/css-media-queries/ http://css-tricks.com/css-media-queries/ Really cool stuff.
- p4bl0 14y agoThe only time I've wanted to use attr() was with :after and it was to customize a picture gallery using only CSS, I wanted to display under each picture its caption which was in the alt attribute, but nowhere in the HTML. Unfortunately :after and :before do not work with the img element…
- jdavis703 14y agoA useful case to use this is for custom tooltips. I'll probably rip out the JS solution in my companies app for the attr function.
- deleted 14y ago[deleted]
- wwweston 14y agoTwo cases I've found in the past: * Styling important content links for print. An anchor tag isn't clickable in print media, potentially leaving important citation information out. You can use attr to put it back in. * Sometimes you find yourself debugging device/browser where you don't have a powerful inspector/debugger. Being able to make attribute data visible can help.