For ages, we couldn’t utilize the sibling combinators (~ and +) to ease the pain of creating star rating widgets, because of this stupid Webkit bug. Nowadays, not only it’s fixed, but the fix has already propagated to Chrome and Safari 5.1. So, we can at least use the sibling combinator to make coloring the stars easier.
But can we use no JavaScript for a rating widget and make it just with CSS?
Actually, we can. By adapting Ryan Seddon’s technique for custom radio buttons with CSS, we can turn a series of radio buttons into stars that change colors (for the purposes of this demo they’re just unicode characters that change colors, but in your case they may as well be images) and use the sibling combinator to color the previous stars. A series of radio buttons is what many people use as a star rating widget fallback anyway, so the markup required is not necessarily more than usual. The only thing that needs to be done differently is their reverse ordering: The highest ratings need to go first, due to the way CSS3 selectors work (this limitation might be removed in CSS4, but that’s a long way ahead).
Of course, you’d still need JS to attach an event handler if you want the votes to be registered through AJAX, but that’s not part of the rating widget per se (it could still work as part of a regular form).
What’s best is that it’s fully keyboard accessible (focus and then use keyboard arrows) and screen reader accessible (although VoiceOver will also pronounce the generated stars, but that won’t happen if you use images instead of unicode stars). I’m guessing it could become even more accessible with proper ARIA, but I’ll leave that as an exercise to the commenter 😀
In browsers that don’t support :checked (essentially only IE < 9), it degrades to a series of radio buttons (haven’t verified that it does, but it should do).
So, here it is:
Pingback: Star Ratings With Very Little CSS | Transition Timing()
Pingback: Star Ratings With Very Little CSS | Froey.us()
Pingback: Star Ratings With Very Little CSS()
Pingback: Star Ratings With Very Little CSS « JoinOG()
Pingback: Powerful New CSS- and JavaScript Techniques | t1u()
Pingback: Powerful New CSS- and JavaScript Techniques@smashing | seo博客大全()
Pingback: Powerful New CSS- and JavaScript Techniques | Buypappa blog()
Pingback: Powerful New CSS- and JavaScript Techniques | MyOfflineTheme.com Skyrocket Your Offline Business Just Now()
Pingback: Powerful New CSS- and JavaScript Techniques | Web Design Kingston()
Pingback: Powerful New CSS- and JavaScript Techniques | DigitalMofo()
Pingback: Steve deGuzmanPowerful New CSS- and JavaScript Techniques » Steve deGuzman()
Pingback: Powerful New CSS- and JavaScript Techniques « Web Development Website()
Pingback: Powerful New CSSand JavaScript Techniques - rehavaPress()
Pingback: Rutweb Technology : Powerful New CSS- and JavaScript Techniques()
Pingback: Powerful New CSS- and JavaScript Techniques | TuTsRUS - All Adobe Tutorials - Photoshop | Illustrator | Encore | Premeire | After Effects()
Pingback: Powerful New CSS- and JavaScript Techniques — Заметки по дизайну()
Pingback: Powerful New CSS- and JavaScript-Techniques (2012 Edition) | Smashing Coding()
Pingback: Powerful New CSS- and JavaScript Techniques | Sedation Dentist Wayne()
Pingback: Powerful New CSS – and JavaScript Techniques()
Pingback: Pure CSS star rating widget focusing on top when click on Firefox - feed99()
Pingback: Powerful New CSS- and JavaScript Techniques()
Pingback: » CSS TRANSAZIONI E ANIMAZIONI - PYG studio()
Pingback: Bergstrom Productions Powerful New CSS- and JavaScript Techniques | Bergstrom Productions()
Pingback: Button Switches with Checkboxes and CSS3 Fanciness | Developer Junk()
Pingback: 用单选按钮和 CSS3 技巧制作按键式开关 | 5迷3道 | HTML5和CSS3的真材实料()
Pingback: 10 Awesome jQuery Rating Plugins | Websanova()
Pingback: Powerful New CSS- and JavaScript Techniques « OhMyDev()
Pingback: Tıklanmaları Javascript yerine CSS ile işlemlemek()
Pingback: Powerful New CSS- and JavaScript-Techniques (2012 Edition)()
Pingback: BUTTON SWITCHES WITH CHECKBOXES AND CSS3 FANCINESS()
Pingback: Using Font Awesome in an Accessible, Bindable Star Rating Control | They Call Me Mister James()
Pingback: よく見るレーティングスターの設定・カスタマイズ | SIDACONFIG()
Pingback: Star Ratings in Rails Using CSS | Swift Horseman()
Pingback: Google()
Pingback: vehicle gps tracker()
Pingback: school of dents()
Pingback: Buy cheap ig followers()
Pingback: kona premium estate()
Pingback: Opciones Binarias 2016()
Pingback: Bamboo Floor()
Pingback: chanel brillen()
Pingback: here()
Pingback: car repair()
Pingback: Get More Info()
Pingback: pdr training()
Pingback: best search engine()
Pingback: bridal lingerie()
Pingback: Cloud hosting()
Pingback: go to my blog()
Pingback: Watch Auctions()
Pingback: Personal GPS Tracker()
Pingback: Wristwatches()
Pingback: Watch Auctions()
Pingback: use this link()
Pingback: read()
Pingback: sup fishing()
Pingback: www.buyfansmedia.com()
Pingback: course in pdr()
Pingback: AG Dental plus Thailand()
Pingback: background checks()
Pingback: bespoke logo eyelets()
Pingback: woodworking tools supplies()
Pingback: custom leather rivets()
Pingback: long prong metal snaps()
Pingback: tack buttons()
Pingback: pearl prong western snaps()
Pingback: press studs()
Pingback: sewing snaps tool()
Pingback: covered prong snaps()
Pingback: stock mount racing shocks()
Pingback: convert to mp3()
Pingback: donate your car for kids()
Pingback: Buy YouTube Views()
Pingback: toddler dentist()
Pingback: Quality Control Service()
Pingback: Exhibition Pop Up Stands()
Pingback: bantningspiller()
Pingback: 3m Banner Stands()
Pingback: Exhibition Pop Up Stands()
Pingback: Stand Banner()
Pingback: book store()
Pingback: Cheap wireless Speaker()