Archive for March, 2011

X-UA-Compatible and HTML5

When Microsoft released IE8, they added a way of ensuring which rendering mode the browser uses. You do it by setting a non-standard header, either with a meta element in your HTML or by configuring your web server to send the header as part of the HTTP response. A lot more details can be found in Defining Document Compatibility (that URL looks far from stable, so don’t be surprised if it doesn’t work).

Always making sure to use a doctype that triggers full standards mode I’ve never encountered a need to use this myself, but I encountered it recently on a couple of sites. What I noticed was that using the following meta element to set the compatibility header will cause a validation error (Bad value “X-UA-Compatible� for attribute “http-equiv� on element “meta�) in HTML5:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Read full post

Posted in , , .



Desktop Wallpaper Calendar: April 2011

Advertisement in Desktop Wallpaper Calendar: April 2011
 in Desktop Wallpaper Calendar: April 2011  in Desktop Wallpaper Calendar: April 2011  in Desktop Wallpaper Calendar: April 2011

We always try our best to challenge your artistic abilities and produce some interesting, beautiful and creative artwork. And as designers we usually turn to different sources of inspiration. As a matter of fact, we’ve discovered the best one — desktop wallpapers that are a little more distinctive than the usual crowd. This creativity mission has been going on for almost two years now, and we are very thankful to all designers who have contributed and are still diligently contributing each month.

We continue to nourish you with a monthly spoon of inspiration. This post features 35 free desktop wallpapers created by artists across the globe for April 2011. Both versions with a calendar and without a calendar can be downloaded for free. It’s time to freshen up your wallpaper!

Please note that:

  • All images can be clicked on and lead to the preview of the wallpaper,
  • You can feature your work in our magazine by taking part in our Desktop Wallpaper Calendar series. We are regularly looking for creative designers and artists to be featured on Smashing Magazine. Are you one of them?

Pablo Cesar

"Pablo Cesar — not exactly a lone ranger — yet here he is, to defend your right to publish." Designed by Inet-design from Denmark.

Pablo Cesar 66 in Desktop Wallpaper Calendar: April 2011

Sakura

"Spring is finally here with its sweet Sakura’s flowers, which reminds me of my trip in Japan last year.Pray and support Japan !" Designed by Laurence Vagner from France.

Prunus 48 in Desktop Wallpaper Calendar: April 2011

Glowing Subway

"Well, I am still learning Blender 2.5 and so I wanted to create a nice wallpaperwith this program. I tried to use different techniques to realise this picture, such asEnvironment and Indirect Lightning and I desired to experiment Depth of Field." Designed by Claudio Lione from Germany.

Glowing Subway 32 in Desktop Wallpaper Calendar: April 2011

April Promise

Designed by Jonathan Carroll from Scotland.

April Promise 6 in Desktop Wallpaper Calendar: April 2011

Blooming

"Blooming tulips- a sign that spring is truly here." Designed by Britt Wilcox from USA.

Blooming 35 in Desktop Wallpaper Calendar: April 2011

Championship

"Time for hockey!" Designed by Jaro Mlkvy from Slovakia.

Championship 4 in Desktop Wallpaper Calendar: April 2011

Sun/clouds

"Enjoy the first warm sunrays in April! (at least in Middle Europe)." Designed by Marco Palma from Italy/Germany.

Sun 82 in Desktop Wallpaper Calendar: April 2011

Typeholic

Designed by Knsqnt Interactive from Germany.

Typeholic 26 in Desktop Wallpaper Calendar: April 2011

Two Birds

"Welcome, Spring! :)." Designed by Anca Varsandan from Romania.

Two Birds 17 in Desktop Wallpaper Calendar: April 2011

April Showers

"April showers bring May flowers and umbrellas. This is my daughter posing under the greenery." Designed by Kerry Shellborn from Canada.

April Showers 33 in Desktop Wallpaper Calendar: April 2011

Spider Web

Designed by Sureshsathanur from India.

Spider Web 68 in Desktop Wallpaper Calendar: April 2011

Usher In The Year Of The Rabbit

"Everyone gets a chance to play the fool this coming April’s Fool." Designed by Siewhui from Singapore.

Hand 58 in Desktop Wallpaper Calendar: April 2011

Help Japan

"Being Japanese Canadian and watching the devastation in Japan on television is heart breaking. I can only imagine how my friends and family living in Japan must feel. I admittedly avoided seeing images of the aftermath for at least a day or two, worried that I would start to cry. Instead I donated money and hoped that the reports I was hearing were exaggerated. Once I saw the scale of the destruction and finally saw images and video of what was happening in Japan, my heart started hurting. On the one hand I was happy to know my family was safe, however, on the other hand I knew this would be the start of even harder times for Japan, especially regarding their recent economic struggles. I could not just sit by and pray or hope, I needed to find a way to raise more funds.This is a wallpaper version of the second design in a Help Japan poster series representing the grace and calm that the Japanese people displayed when a tragic act of nature was struck upon them.All profits from the sale of the posters in the series will go to the Canadian Red Cross efforts for the victims affected by the recent tsunami and earthquakes." Designed by Linda Nakanishi from Canada.

Helpjapan 77 in Desktop Wallpaper Calendar: April 2011

The Smashing Wall

"The Smashing Wall showcases a new concept of creating virtual shelves or menus so that one can place the desktop icons in the slots provided to create a beautiful virtual effect and a super neat desktop wallpaper with all icons sorted in one place." Designed by Chetan from India.

The Smashing Wall 52 in Desktop Wallpaper Calendar: April 2011

Something Wrong

"We are a group of young Syrians, we create and publish CC licensed comics on our website. This wallpaper was created for our pilot series (Something Wrong)." Designed by Homeless from Syria.

Something Wrong 48 in Desktop Wallpaper Calendar: April 2011

Springlight

"We love spring colors – from pastels to neutrals to bright colors!" Designed by Lotum from Germany.

Springlight 63 in Desktop Wallpaper Calendar: April 2011

Psychedelic Spring Fairy

"The reference photo of the fairy was taken by Marcus Ranum." Designed by Andrei Verner from Russia.

Psychedelic Spring Fairy 46 in Desktop Wallpaper Calendar: April 2011

Easter Flower

Designed by Nathalie Lansbergen from the Netherlands.

Easter Flower 9 in Desktop Wallpaper Calendar: April 2011

Fool’s Day

"April 1st is Fool’s Day. Don’t be afraid of being fool on other days, too." Designed by Olivia Osik from Estonia.

Fools Day 51 in Desktop Wallpaper Calendar: April 2011

Silly Sheep

Designed by Pietje Precies from The Netherlands.

Silly Sheep 14 in Desktop Wallpaper Calendar: April 2011

Spring Is Here

"Wishing all of you a colourful and cheerful spring!" Designed by Ron Gilad from Israel.

Spring Is Here 20 in Desktop Wallpaper Calendar: April 2011

Alien

"he Fools’ day is not the only holiday april is known for. Where is also april 12 – Cosmonautics Day in Russia. That day in 1961 the first man ever circled Earth in a spacecraft." Designed by Cheloveche.ru from Russia.

Alien 76 in Desktop Wallpaper Calendar: April 2011

Calendar Mz

Designed by Mz from Poland.

Calendar3 33 in Desktop Wallpaper Calendar: April 2011

April Showers

"Artwork from QR Codes." Designed by Jason Smith – Layer One Graphics from USA.

April 14 in Desktop Wallpaper Calendar: April 2011

Illustration

"An Art Nouveau inspired piece to give warmth and happiness at the start of spring. One of the flowers associated with spring is the daffodil and I used this within my design so that the the girls long flowing hair and ballet-like stance created this beautiful flower." Designed by Heather Williams from United Kingdom.

Flower Girl 65 in Desktop Wallpaper Calendar: April 2011

Temple Of Icons

"The story of the battle from the Temple of the Desktop Icons, fiercely guarded by the Dragon and the seven ninja warriors." Designed by Pal Ovidiu from Romania.

Temple Of Icons 93 in Desktop Wallpaper Calendar: April 2011

Scissors Trap

"These scissors have made a trap in a quite recursive manner. It`s not supposed to blow your head out of laughing, but when it puts a smile on your face it`s just fine :)." Designed by Marek Chrenko from Slovakia.

Scissors Trap 74 in Desktop Wallpaper Calendar: April 2011

Vector Saraswathi

"Saraswathi – Goddess of Creativity (Indian Mythology) by Atma Studios." Designed by Atma Creative Team from India.

Vector Saraswathi 93 in Desktop Wallpaper Calendar: April 2011

Spring Is Coming

"Go outside with Nerd !" Designed by Nerdart Team from Poland.

Spring Is Coming 73 in Desktop Wallpaper Calendar: April 2011

Poster Bunny

"A cheeky poster bunny just couldn’t resist the tempting easter egg." Designed by Isis from Malaysia.

Poster Bunny 43 in Desktop Wallpaper Calendar: April 2011

The Infanta

"A remake on the Infanta Margarita from Las Meninas by Velazquez." Designed by Cindy Zhang from USA.

Infanta 29 in Desktop Wallpaper Calendar: April 2011

April Showers Bring May Flowers

"This is based on the proverb “April showers bring May flowers”." Designed by Jusna Begum from UK.

April Showers Bring May Flowers 80 in Desktop Wallpaper Calendar: April 2011

Ghilli Du

"This is a digital illustration made for giclee printing, inspired by the performancedone by Titi Dimak for my performance art video “The Inanimate.” http://vimeo.com/17354393." Designed by Riki K. from USA.

Du 35 in Desktop Wallpaper Calendar: April 2011

Steve In A Pit

"Here, Steve the dog is in a bit of trouble as he wakes up at the edge of a pit. It might be endless, but then againit might be ten foot deep. Either way, PERIL AND ADVENTURE ENSUES!" Designed by Michael Georgiou from United Kingdom.

Steve Pit 1 in Desktop Wallpaper Calendar: April 2011

Bonus: Smashing Twitter Icons

"The wallpapers consist of about 5000 genuine, original, most beautiful twitter icons harvested over a period of time on twitter. The wallpaper sized 2000×2000 consists of all 5000, the rest fit less." Designed by Agnieszka Anna from USA.

Smash Twitter 66 in Desktop Wallpaper Calendar: April 2011

Join in next month!

Please note that we respect and carefully consider the ideas and motivation behind each and every artist’s work. This is why we give all artists the full freedom to explore their creativity and express emotions and experience throughout their works. This is also why the themes of the wallpapers weren’t anyhow influenced by us, but rather designed from scratch by the artists themselves.

A big thank you to all designers for their participation. Join in next month!

What’s your favorite?

What’s your favorite theme or wallpaper for this month? Please let us know in the comment section below.

(ik) (vf)


© Smashing Editorial for Smashing Magazine, 2011. | Permalink | Post a comment | Smashing Shop | Smashing Network | About Us
Post tags:


Desktop Wallpaper Calendar: April 2011

Advertisement in Desktop Wallpaper Calendar: April 2011
 in Desktop Wallpaper Calendar: April 2011  in Desktop Wallpaper Calendar: April 2011  in Desktop Wallpaper Calendar: April 2011

We always try our best to challenge your artistic abilities and produce some interesting, beautiful and creative artwork. And as designers we usually turn to different sources of inspiration. As a matter of fact, we’ve discovered the best one — desktop wallpapers that are a little more distinctive than the usual crowd. This creativity mission has been going on for almost two years now, and we are very thankful to all designers who have contributed and are still diligently contributing each month.

We continue to nourish you with a monthly spoon of inspiration. This post features 35 free desktop wallpapers created by artists across the globe for April 2011. Both versions with a calendar and without a calendar can be downloaded for free. It’s time to freshen up your wallpaper!

Please note that:

  • All images can be clicked on and lead to the preview of the wallpaper,
  • You can feature your work in our magazine by taking part in our Desktop Wallpaper Calendar series. We are regularly looking for creative designers and artists to be featured on Smashing Magazine. Are you one of them?

Pablo Cesar

"Pablo Cesar — not exactly a lone ranger — yet here he is, to defend your right to publish." Designed by Inet-design from Denmark.

Pablo Cesar 66 in Desktop Wallpaper Calendar: April 2011

Sakura

"Spring is finally here with its sweet Sakura’s flowers, which reminds me of my trip in Japan last year. Pray and support Japan !" Designed by Laurence Vagner from France.

Prunus 48 in Desktop Wallpaper Calendar: April 2011

Glowing Subway

"Well, I am still learning Blender 2.5 and so I wanted to create a nice wallpaperwith this program. I tried to use different techniques to realise this picture, such asEnvironment and Indirect Lightning and I desired to experiment Depth of Field." Designed by Claudio Lione from Germany.

Glowing Subway 32 in Desktop Wallpaper Calendar: April 2011

April Promise

Designed by Jonathan Carroll from Scotland.

April Promise 6 in Desktop Wallpaper Calendar: April 2011

Blooming

"Blooming tulips- a sign that spring is truly here." Designed by Britt Wilcox from USA.

Blooming 35 in Desktop Wallpaper Calendar: April 2011

Championship

"Time for hockey!" Designed by Jaro Mlkvy from Slovakia.

Championship 4 in Desktop Wallpaper Calendar: April 2011

Sun/clouds

"Enjoy the first warm sunrays in April! (at least in Middle Europe)." Designed by Marco Palma from Italy/Germany.

Sun 82 in Desktop Wallpaper Calendar: April 2011

Typeholic

Designed by Knsqnt Interactive from Germany.

Typeholic 26 in Desktop Wallpaper Calendar: April 2011

Two Birds

"Welcome, Spring! :)." Designed by Anca Varsandan from Romania.

Two Birds 17 in Desktop Wallpaper Calendar: April 2011

April Showers

"April showers bring May flowers and umbrellas. This is my daughter posing under the greenery." Designed by Kerry Shellborn from Canada.

April Showers 33 in Desktop Wallpaper Calendar: April 2011

Spider Web

Designed by Sureshsathanur from India.

Spider Web 68 in Desktop Wallpaper Calendar: April 2011

Usher In The Year Of The Rabbit

"Everyone gets a chance to play the fool this coming April’s Fool." Designed by Siewhui from Singapore.

Hand 58 in Desktop Wallpaper Calendar: April 2011

Help Japan

"Being Japanese Canadian and watching the devastation in Japan on television is heart breaking. I can only imagine how my friends and family living in Japan must feel. I admittedly avoided seeing images of the aftermath for at least a day or two, worried that I would start to cry. Instead I donated money and hoped that the reports I was hearing were exaggerated. Once I saw the scale of the destruction and finally saw images and video of what was happening in Japan, my heart started hurting. On the one hand I was happy to know my family was safe, however, on the other hand I knew this would be the start of even harder times for Japan, especially regarding their recent economic struggles. I could not just sit by and pray or hope, I needed to find a way to raise more funds.This is a wallpaper version of the second design in a Help Japan poster series representing the grace and calm that the Japanese people displayed when a tragic act of nature was struck upon them.All profits from the sale of the posters in the series will go to the Canadian Red Cross efforts for the victims affected by the recent tsunami and earthquakes." Designed by Linda Nakanishi from Canada.

Helpjapan 77 in Desktop Wallpaper Calendar: April 2011

The Smashing Wall

"The Smashing Wall showcases a new concept of creating virtual shelves or menus so that one can place the desktop icons in the slots provided to create a beautiful virtual effect and a super neat desktop wallpaper with all icons sorted in one place." Designed by Chetan from India.

The Smashing Wall 52 in Desktop Wallpaper Calendar: April 2011

Something Wrong

"We are a group of young Syrians, we create and publish CC licensed comics on our website. This wallpaper was created for our pilot series (Something Wrong)." Designed by Homeless from Syria.

Something Wrong 48 in Desktop Wallpaper Calendar: April 2011

Springlight

"We love spring colors – from pastels to neutrals to bright colors!" Designed by Lotum from Germany.

Springlight 63 in Desktop Wallpaper Calendar: April 2011

Psychedelic Spring Fairy

"The reference photo of the fairy was taken by Marcus Ranum." Designed by Andrei Verner from Russia.

Psychedelic Spring Fairy 46 in Desktop Wallpaper Calendar: April 2011

Easter Flower

Designed by Nathalie Lansbergen from the Netherlands.

Easter Flower 9 in Desktop Wallpaper Calendar: April 2011

Fool’s Day

"April 1st is Fool’s Day. Don’t be afraid of being fool on other days, too." Designed by Olivia Osik from Estonia.

Fools Day 51 in Desktop Wallpaper Calendar: April 2011

Silly Sheep

Designed by Pietje Precies from The Netherlands.

Silly Sheep 14 in Desktop Wallpaper Calendar: April 2011

Spring Is Here

"Wishing all of you a colourful and cheerful spring!" Designed by Ron Gilad from Israel.

Spring Is Here 20 in Desktop Wallpaper Calendar: April 2011

Alien

"he Fools’ day is not the only holiday april is known for. Where is also april 12 – Cosmonautics Day in Russia. That day in 1961 the first man ever circled Earth in a spacecraft." Designed by Cheloveche.ru from Russia.

Alien 76 in Desktop Wallpaper Calendar: April 2011

Calendar Mz

Designed by Mz from Poland.

Calendar3 33 in Desktop Wallpaper Calendar: April 2011

April Showers

"Artwork from QR Codes." Designed by Jason Smith – Layer One Graphics from USA.

April 14 in Desktop Wallpaper Calendar: April 2011

Illustration

"An Art Nouveau inspired piece to give warmth and happiness at the start of spring. One of the flowers associated with spring is the daffodil and I used this within my design so that the the girls long flowing hair and ballet-like stance created this beautiful flower." Designed by Heather Williams from United Kingdom.

Flower Girl 65 in Desktop Wallpaper Calendar: April 2011

Temple Of Icons

"The story of the battle from the Temple of the Desktop Icons, fiercely guarded by the Dragon and the seven ninja warriors." Designed by Pal Ovidiu from Romania.

Temple Of Icons 93 in Desktop Wallpaper Calendar: April 2011

Scissors Trap

"These scissors have made a trap in a quite recursive manner. It`s not supposed to blow your head out of laughing, but when it puts a smile on your face it`s just fine :)." Designed by Marek Chrenko from Slovakia.

Scissors Trap 74 in Desktop Wallpaper Calendar: April 2011

Vector Saraswathi

"Saraswathi – Goddess of Creativity (Indian Mythology) by Atma Studios." Designed by Atma Creative Team from India.

Vector Saraswathi 93 in Desktop Wallpaper Calendar: April 2011

Spring Is Coming

"Go outside with Nerd !" Designed by Nerdart Team from Poland.

Spring Is Coming 73 in Desktop Wallpaper Calendar: April 2011

Poster Bunny

"A cheeky poster bunny just couldn’t resist the tempting easter egg." Designed by Isis from Malaysia.

Poster Bunny 43 in Desktop Wallpaper Calendar: April 2011

The Infanta

"A remake on the Infanta Margarita from Las Meninas by Velazquez." Designed by Cindy Zhang from USA.

Infanta 29 in Desktop Wallpaper Calendar: April 2011

April Showers Bring May Flowers

"This is based on the proverb “April showers bring May flowers”." Designed by Jusna Begum from UK.

April Showers Bring May Flowers 80 in Desktop Wallpaper Calendar: April 2011

Ghilli Du

"This is a digital illustration made for giclee printing, inspired by the performancedone by Titi Dimak for my performance art video “The Inanimate.” http://vimeo.com/17354393." Designed by Riki K. from USA.

Du 35 in Desktop Wallpaper Calendar: April 2011

Steve In A Pit

"Here, Steve the dog is in a bit of trouble as he wakes up at the edge of a pit. It might be endless, but then againit might be ten foot deep. Either way, PERIL AND ADVENTURE ENSUES!" Designed by Michael Georgiou from United Kingdom.

Steve Pit 1 in Desktop Wallpaper Calendar: April 2011

Bonus: Smashing Twitter Icons

"The wallpapers consist of about 5000 genuine, original, most beautiful twitter icons harvested over a period of time on twitter. The wallpaper sized 2000×2000 consists of all 5000, the rest fit less." Designed by Agnieszka Anna from USA.

Smash Twitter 66 in Desktop Wallpaper Calendar: April 2011

Join in next month!

Please note that we respect and carefully consider the ideas and motivation behind each and every artist’s work. This is why we give all artists the full freedom to explore their creativity and express emotions and experience throughout their works. This is also why the themes of the wallpapers weren’t anyhow influenced by us, but rather designed from scratch by the artists themselves.

A big thank you to all designers for their participation. Join in next month!

What’s your favorite?

What’s your favorite theme or wallpaper for this month? Please let us know in the comment section below.

(ik) (vf)


© Smashing Editorial for Smashing Magazine, 2011. | Permalink | Post a comment | Smashing Shop | Smashing Network | About Us
Post tags:


Can You See Me? Unbelievable Animal Camouflage Photography

Advertisement in Can You See Me? Unbelievable Animal Camouflage Photography
 in Can You See Me? Unbelievable Animal Camouflage Photography  in Can You See Me? Unbelievable Animal Camouflage Photography  in Can You See Me? Unbelievable Animal Camouflage Photography

Many creatures use their weapon of camouflaging themselves whenever they sense danger within their habitats. This is one of the many stunning characteristics of nature as this ability enhances their chances of survival.

Each animal has a specific custom-made camouflage pattern for the peculiar surroundings that it acclimatizes. In this collection, we have assembled some beautiful animal and insect photography that demonstrates the amazing camouflage patterns which helps them hide themselves almost completely in their surroundings.

Hidden Spider

Camouflageanimals321 in Can You See Me? Unbelievable Animal Camouflage Photography

Hidden Owl In Tree

Camouflageanimals19 in Can You See Me? Unbelievable Animal Camouflage Photography

Lizard Camouflage

Camouflageanimals4 in Can You See Me? Unbelievable Animal Camouflage Photography

Crinoid Shrimp

Camouflageanimals9 in Can You See Me? Unbelievable Animal Camouflage Photography

Larva de Pieris Rapae

Camouflageanimals6 in Can You See Me? Unbelievable Animal Camouflage Photography

Uroplatus sikorae – Mossy Leaf-tailed Gecko

Camouflageanimals3 in Can You See Me? Unbelievable Animal Camouflage Photography

Allied Cowrie

Camouflageanimals8 in Can You See Me? Unbelievable Animal Camouflage Photography

STONEFISH

Camouflageanimals10 in Can You See Me? Unbelievable Animal Camouflage Photography

Hidden Tiger

Camouflageanimals54 in Can You See Me? Unbelievable Animal Camouflage Photography

Elephant

Camouflageanimals44 in Can You See Me? Unbelievable Animal Camouflage Photography

Mimetismo “quase” perfeito

Camouflageanimals12 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflaged spider from closer – Ocyale guttata

Camouflageanimals14 in Can You See Me? Unbelievable Animal Camouflage Photography

Stick Mimic

Camouflageanimals15 in Can You See Me? Unbelievable Animal Camouflage Photography

Chameleon

Camouflageanimals17 in Can You See Me? Unbelievable Animal Camouflage Photography

Phyllomimus sp. (Tettigoniidae: Pseudophyllinae)

Camouflageanimals18 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflage

Camouflageanimals20 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflage Alligator

Camouflageanimals7 in Can You See Me? Unbelievable Animal Camouflage Photography

CAMOUFLAGE – AMAZING OWL

Camouflageanimals21 in Can You See Me? Unbelievable Animal Camouflage Photography

A Pale-throated three-toed sloth climbs a tree trunk is Costa Rica

Camouflageanimals51 in Can You See Me? Unbelievable Animal Camouflage Photography

Transparent Butterfly

Camouflageanimals22 in Can You See Me? Unbelievable Animal Camouflage Photography

Seahorse in Early Morning

Camouflageanimals24 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflaged dragonfly on a Rock

Camouflageanimals25 in Can You See Me? Unbelievable Animal Camouflage Photography

The Natural Camouflage of the Rock behind the Elephant

Camouflageanimals26 in Can You See Me? Unbelievable Animal Camouflage Photography

Uroplatus sikorae sikorae

Camouflageanimals28 in Can You See Me? Unbelievable Animal Camouflage Photography

Look Carefully Before You Jump into that Leaf Pile

Camouflageanimals29 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflage Frog

Camouflageanimals31 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflage

Camouflageanimals34 in Can You See Me? Unbelievable Animal Camouflage Photography

Hidden Snake

Camouflageanimals35 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflaged Croc

Camouflageanimals36 in Can You See Me? Unbelievable Animal Camouflage Photography

Lizard Camouflage

Camouflageanimals37 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflaged Rattlesnake

Camouflageanimals38 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflageanimals39 in Can You See Me? Unbelievable Animal Camouflage Photography

Crazy Camouflage

Camouflageanimals40 in Can You See Me? Unbelievable Animal Camouflage Photography

Can you find Frog?

Camouflageanimals33 in Can You See Me? Unbelievable Animal Camouflage Photography

Camouflaged Ladybug

Camouflageanimals42 in Can You See Me? Unbelievable Animal Camouflage Photography

Knobbly crab spider.

Camouflageanimals46 in Can You See Me? Unbelievable Animal Camouflage Photography

Hidden zebra

Camouflageanimals48 in Can You See Me? Unbelievable Animal Camouflage Photography

A goby camouflaged on a sandy sea floor

Camouflageanimals49 in Can You See Me? Unbelievable Animal Camouflage Photography

A Locust mimicks a blade of grass in Burkina Faso

Camouflageanimals50 in Can You See Me? Unbelievable Animal Camouflage Photography

Butterfly in Disguise

Camouflageanimals53 in Can You See Me? Unbelievable Animal Camouflage Photography


How To Use CSS3 Pseudo-Classes

Advertisement in How To Use CSS3 Pseudo-Classes
 in How To Use CSS3 Pseudo-Classes  in How To Use CSS3 Pseudo-Classes  in How To Use CSS3 Pseudo-Classes

CSS3 is a wonderful thing, but it’s easy to be bamboozled by the transforms and animations (many of which are vendor-specific) and forget about the nuts-and-bolts selectors that have also been added to the specification. A number of powerful new pseudo-selectors (16 are listed in the latest W3C spec) enable us to select elements based on a range of new criteria.

Css3 in How To Use CSS3 Pseudo-Classes

Before we look at these new CSS3 pseudo-classes, let’s briefly delve into the dusty past of the Web and chart the journey of these often misunderstood selectors.

A Brief History Of Pseudo-Classes

When the CSS1 spec was completed back in 1996, a few pseudo-selectors were included, many of which you probably use almost every day. For example:

  • :link
  • :visited
  • :hover
  • :active

Each of these states can be applied to an element, usually <a>, after which comes the name of the pseudo-class. It’s amazing to think that these pseudo-classes arrived on the scene before HTML4 was published by the W3C a year later in December 1997.

CSS2 Arrives

Hot on the heels of CSS1 was CSS2, whose recommended spec was published just two years later in May 1998. Along with exciting things like positioning were new pseudo-classes: :first-child and :lang().

:lang
There are a couple of ways to indicate the language of a document, and if you’re using HTML5, it’ll likely be by putting <html lang="en"> just after the doc type (specifying your local language, of course). You can now use :lang(en) to style elements on a page, which is useful when the language changes dynamically.

:first-child
You may have already used :first-child in your documents. It is often used to add or remove a top border on the first element in a list. Strange, then, that it wasn’t accompanied by :last-child; we had to wait until CSS3 was proposed before it could meet its brother.

Why Use Pseudo-Classes?

What makes pseudo-classes so useful is that they allow you to style content dynamically. In the <a> example above, we are able to describe how links are styled when the user interacts with them. As we’ll see, the new pseudo-classes allow us to dynamically style content based on its position in the document or its state.

Sixteen new pseudo-classes have been introduced as part of the W3C’s CSS Proposed Recommendation, and they are broken down into four groups: structural pseudo-classes, pseudo-classes for the states of UI elements, a target pseudo-class and a negation pseudo-class.

W3c in How To Use CSS3 Pseudo-Classes
The W3C is the home of CSS.

Let’s now run through the 16 new pseudo-selectors one at a time and see how each is used. I’ll use the same notation for naming classes that the W3C uses, where E is the element, n is a number and s is a selector.

Sample Code

For many of these new selectors, I’ll also refer to some sample code so that you can see what effect the CSS has. We’ll take a regular form and make it suitable for an iPhone using our new CSS3 pseudo-classes.

Note that we could arguably use ID and class selectors for much of this form, but it’s a great opportunity to take our new pseudo-classes out for a spin and demonstrate how you might use them in a real-world example. Here’s the HTML (which you can see in action on my website):

<form>
 <hgroup>
 <h1>Awesome Widgets</h1>
 <h2>All the cool kids have got one :)</h2>
 </hgroup>
 <fieldset id="email">
 <legend>Where do we send your receipt?</legend>
 <label for="email">Email Address</label>
 <input type="email" name="email" placeholder="Email Address" />
 </fieldset>

 <fieldset id="details">
 <legend>Personal Details</legend>
 <select name="title" id="field_title">
  <option value="" selected="selected">Title</option>
  <option value="Mr">Mr</option>
  <option value="Mrs">Mrs</option>
  <option value="Miss">Miss</option>
 </select>

 <label for="firstname">First Name</label>
 <input name="firstname" placeholder="First Name" />

 <label for="initial">Initial</label>
 <input name="initial" placeholder="Initial" size="3" />

 <label for="surname">Surname</label>
 <input name="surname" placeholder="Surname" />
 </fieldset>

 <fieldset id="payment">
 <legend>Payment Details</legend>

 <label for="cardname">Name on card</label>
 <input name="cardname" placeholder="Name on card" />

 <label for"cardnumber">Card number</label>
 <input name="cardnumber" placeholder="Card number" />

 <select name="cardType" id="field_cardType">
  <option value="" selected="selected">Select Card Type</option>
  <option value="1">Visa</option>
  <option value="2">American Express</option>
  <option value="3">MasterCard</option>
 </select>

 <label for="cardExpiryMonth">Expiry Date</label>
 <select id="field_cardExpiryMonth" name="cardExpiryMonth">
  <option selected="selected" value="mm">MM</option>
   <option value="01">01</option>
   <option value="02">02</option>
   <option value="03">03</option>
   <option value="04">04</option>
   <option value="05">05</option>
   <option value="06">06</option>
   <option value="07">07</option>
   <option value="08">08</option>
   <option value="09">09</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12</option>
 </select> /
 <select id="field_cardExpiryYear" name="cardExpiryYear">
   <option value="yyyy">YYYY</option>
    <option value="2011">11</option>
    <option value="2012">12</option>
    <option value="2013">13</option>
    <option value="2014">14</option>
    <option value="2015">15</option>
    <option value="2016">16</option>
    <option value="2017">17</option>
    <option value="2018">18</option>
    <option value="2019">19</option>
 </select>

 <label for"securitycode">Security code</label>
 <input name="securitycode" type="number" placeholder="Security code" size="3" />

 <p>Would you like Insurance?</p>
 <input type="radio" name="Insurance" id="insuranceYes" />
  <label for="insuranceYes">Yes Please!</label>
 <input type="radio" name="Insurance" id="insuranceNo" />
  <label for="insuranceNo">No thanks</label>

 </fieldset>

 <fieldset id="submit">
 <button type="submit" name="Submit" disabled>Here I come!</button>
 </fieldset>
</form>

Before-after in How To Use CSS3 Pseudo-Classes
Our form, before and after.

1. Structural Pseudo-Classes

According to the W3C, structural pseudo-classes do the following:

… permit selection based on extra information that lies in the document tree but cannot be represented by other simple selectors or combinators.

What this means is that we have selectors that have been turbo-charged to dynamically select content based on its position in the document. So let’s start at the beginning of the document, with :root.

Selectors-level-screenshot in How To Use CSS3 Pseudo-Classes
Level 3 selectors on the W3C website.

E:root

The :root pseudo-class selects the root element on the page. Ninety-nine times out of a hundred, this will be the <html> element. For example:

:root { background-color: #fcfcfc; }

It’s worth noting that you could style the <html> element instead, which is perhaps a little more descriptive:

html { background-color: #fcfcfc; }

iPhone Form Example
Let’s move over to our sample code and give the document some basic text and background styles:

:root {
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,0.8);
background: url(…/images/background.png) no-repeat #282826; }

E:nth-child(n)

The :nth-child() selector might require a bit of experimentation to fully understand. The easiest implementation is to use the keywords odd or even, which are useful when displaying data that consists of rows or columns. For example, we could use the following:

ul li:nth-child(odd) {
background-color: #666;
color: #fff; }

This would highlight every other row in an unordered list. You might find this technique extremely handy when using tables. For example:

table tr:nth-child(even) { … }

The :nth-child selector can be much more specific and flexible, though. You could select only the third element from a list, like so:

li:nth-child(3) { … }

Note that n does not start at zero, as it might in an array. The first element is :nth-child(1), the second is :nth-child(2) and so on.

We can also use some simple algebra to make things even more exciting. Consider the following:

li:nth-child(2n) { … }

Whenever we use n in this way, it stands for all positive integers (until the document runs out of elements to select!). In this instance, it would select the following list items:

  • Nothing (2 × 0)
  • 2nd element (2 × 1)
  • 4th element (2 × 2)
  • 6th element (2 × 3)
  • 8th element (2 × 4)
  • etc.

This actually gives us the same thing as nth-child(even). So, let’s mix things up a bit:

li:nth-child(5n) { … }

This gives us:

  • Nothing (5 × 0)
  • 5th element (5 × 1)
  • 10th element (5 × 2)
  • 15th element (5 × 3)
  • 20th element (5 × 4)
  • etc.

Perhaps this would be useful for long lists or tables, perhaps not. We can also add and subtract numbers in this equation:

li:nth-child(4n + 1) { … }

This gives us:

  • 1st element ((4 × 0) + 1)
  • 5th element ((4 × 1) + 1)
  • 9th element ((4 × 2) + 1)
  • 13th element ((4 × 3) + 1)
  • 17th element ((4 × 4) + 1)
  • etc.

SitePoint points out an interesting quirk here. If you set n as negative, you’ll be able to select the first x number of items like so:

li:nth-child(-n + x) { … }

Let’s say you want to select the first five items in a list. Here’s the CSS:

li:nth-child(-n + 5) { … }

This gives us:

  • 5th element (-0 + 5)
  • 4th element (-1 + 5)
  • 3rd element (-2 + 5)
  • 2nd element (-3 + 5)
  • 1st element (-4 + 5)
  • Nothing (-5 + 5)
  • Nothing (-6 + 5)
  • etc.

If you’re listing data in order of popularity, then highlighting, say, the top 10 entries might be useful.

WebDesign & Such has created a demo of zebra striping, which is a perfect example of how you might use nth-child in practice.

Zebra-Striping-a-Table-with-CSS3 in How To Use CSS3 Pseudo-Classes
Zebra striping a table with CSS3.

If none of your tables need styling, then you could do what Webvisionary Awards has done and use :nth-child to style alternating sections of its website. Here’s the CSS:

section > section:nth-child(even) {
background:rgba(255,255,255,.1)
url("../images/hr-damaged2.png") 0 bottom no-repeat;
}

The effect is subtle on the website, but it adds a layer of detail that would be missed in older browsers.

WVA-2011 in How To Use CSS3 Pseudo-Classes
The :nth-child selectors in action on Webvisionary Awards.

iPhone Form Example
We could use :nth-child in a few places in our iPhone form example, but let’s focus on one. We want to hide the labels for the first three fieldsets from view and use the placeholder text instead. Here’s the CSS:

form:nth-child(-n+3) label { display: none; }

Here, we’re looking for the first three children of the <form> element (which are all fieldsets in our code) and then selecting the label. We then hide these labels with display: none;.

E:nth-last-child(n)

Not content with confusing us all with the :nth-child() pseudo-class, the clever folks over at the W3C have also given us :nth-last-child(n). It operates much like :nth-child() except in reverse, counting from the last item in the selection.

li:nth-last-child(1) { … }

The above will select the last element in a list, whereas the following will select the penultimate element:

li:nth-last-child(2) { … }

Of course, you could create other rules, like this one:

li:nth-last-child(2n+1) { … }

But you would more likely want to use the following to select the last five elements of a list (based on the logic discussed above):

li:nth-last-child(-n+5) { … }

If this still doesn’t make much sense, Lea Verou has created a useful CSS3 structural pseudo-class selector tester, which is definitely worth checking out.

CSS3-structural-pseudo-class-selector-tester in How To Use CSS3 Pseudo-Classes
CSS3 structural pseudo-class selector tester.

iPhone Form Example
We can use :nth-last-child in our example to add rounded corners to our input for the “Card number.� Here’s our CSS, which is overly specific but gives you an idea of how we can chain pseudo-selectors together:

fieldset:nth-last-child(2) input:nth-last-of-type(3) {
border-radius: 10px; }

We first grab the penultimate fieldset and select the input that is third from last (in this case, our “Card number� input). We then add a border-radius.

:nth-of-type(n)

Now we’ll get even more specific and apply styles only to particular types of element. For example, let’s say you wanted to style the first paragraph in an article with a larger font. Here’s the CSS:

article p:nth-of-type(1) { font-size: 1.5em; }

Perhaps you want to align every other image in an article to the right, and the others to the left. We can use keywords to control this:

article img:nth-of-type(odd) { float: right; }
article img:nth-of-type(even) { float: left; }

As with :nth-child() and :nth-last-child(), you can use algebraic expressions:

article p:nth-of-type(2n+2) { … }
article p:nth-of-type(-n+1) { … }

It’s worth remembering that if you need to get this specific about targeting elements, then using descriptive class names instead might be more useful.

Simon Foster has created a beautiful infographic about his 45 RPM record collection, and he uses :nth-of-type to style some of the data. Here’s a snippet from the CSS, which assigns a different background to each genre type:

ul#genre li:nth-of-type(1) {
  width:32.9%;
	background:url(images/orangenoise.jpg);
}
ul#genre li:nth-of-type(2) {
  width:15.2%;
	background:url(images/bluenoise.jpg);
}
ul#genre li:nth-of-type(3) {
  width:13.1%;
	background:url(images/greennoise.jpg);
}

And here’s what it looks like on his website:

For-The-Record in How To Use CSS3 Pseudo-Classes
The :nth-of-type selectors on “For the Record.�

iPhone Form Example
Let’s say we want every second input element to have rounded corners on the bottom. We can achieve this with CSS:

input:nth-of-type(even) {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px; }

In our example, we want to apply this only to the fieldset for payment, because the fieldset for personal details has three text inputs. We’ll also get a bit tricky and make sure that we don’t select any of the radio inputs. Here’s the final CSS:

#payment input:nth-of-type(even):not([type=radio]) {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
border-bottom: 1px solid #999;
margin-bottom: 10px; }

We’ll explain :not later in this article.

:nth-last-of-type(n)

Hopefully, by now you see where this is going: :nth-last-of-type() starts at the end of the selected elements and works backwards.

To select the last paragraph in an article, you would use this:

article p:nth-last-of-type(1) { … }

You might want to choose this selector instead of :last-child if your articles don’t always end with paragraphs.

:first-of-type and :last-of-type

If :nth-of-type() and :nth-last-of-type() are too specific for your purposes, then you could use a couple of simplified selectors. For example, instead of this…

article p:nth-of-type(1) {
font-size: 1.5em; }

… we could just use this:

article p:first-of-type {
font-size: 1.5em; }

As you’d expect, :last-of-type works in exactly the same way but from the last element selected.

iPhone Form Example
We can use both :first-of-type and :last-of-type in our iPhone example, particularly when styling the rounded corners. Here’s the CSS:

fieldset input:first-of-type:not([type=radio]) {
border-top-left-radius: 10px;
border-top-right-radius: 10px; }

fieldset input:last-of-type:not([type=radio]) {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px; }

The first line of CSS adds a top rounded border to all :first-of-type inputs in a fieldset that aren’t radio buttons. The second line adds the bottom rounded border to the last input element in a fieldset.

:only-of-type

There’s one more type selector to look at: :only-of-type(). This is useful for selecting elements that are the only one of their kind in their parent element.

For example, consider the difference between this CSS selector…

p {
font-size: 18px; }

… and this one:

p:only-of-type {
font-size: 18px; }

The first selector will style every paragraph element on the page. The second element will grab a paragraph that is the only paragraph in its parent.

This could be handy when you are styling content or data that has been dynamically outputted from a database and the query returns only one result.

Devsnippet has created a demo in which single images are styled differently from multiple images.

Only-of-type-Pseudo-Class in How To Use CSS3 Pseudo-Classes
Devsnippet’s demo for :only-of-type.

iPhone Form Example
In the case of our iPhone example, we can make sure that all inputs that are the only children of a fieldset have rounded corners on both the top and bottom. The CSS would be:

fieldset input:only-of-type {
border-radius: 10px; }

:last-child

It’s a little strange that :first-child was part of the CSS2 spec but that its partner in crime, :last-child, didn’t appear until CSS3. It takes no expressions or keywords here; it simply selects the last child of its parent element. For example:

li {
border-bottom: 1px solid #ccc; }

li:last-child {
border-bottom: none; }

This is a useful way to remove bottom borders from lists. You’ll see this technique quite often in WordPress widgets.

Rachel Andrew looks at :last-child and other CSS pseudo-selectors in her 24 Ways article “Cleaner Code With CSS3 Selectors.� Rachel shows us how to use this selector to create a well-formatted image gallery without additional classes.

Screen-shot-2011-03-22-at-21 49 46 in How To Use CSS3 Pseudo-Classes
The CSS for :last-child in action, courtesy of Rachel Andrew.

:only-child

If an element is the only child of its parent, then you can select it with :only-child. Unlike with :only-of-type, it doesn’t matter what type of element it is. For example:

li:only-child { … }

We could use this to select list elements that are the only list elements in their <ol> or <ul> parent.

:empty

Finally, in structural pseudo-classes, we have :empty. Not surprisingly, this selects only elements that have no children and no content. Again, this might be useful when dealing with dynamic content outputted from a database.

#results:empty {
background-color: #fcc; }

You might use the above to draw the user’s attention to an empty search results section.

2. The Target Pseudo-Class

:target

This is one of my favourite pseudo-classes, because it allows us to style elements on the page based on the URL. If the URL has an identifier (that follows an #), then the :target pseudo-class will style the element that shares the ID with the identifier. Take a URL that looks like this:

http://www.example.com/css3-pseudo-selectors#summary

The section with the id summary can now be styled like so:

:target {
background-color: #fcc; }

This is a great way to style elements on pages that have been linked to from external content. You could also use it with internal anchors to highlight content that users have skipped to.

Perhaps the most impressive use of :target I’ve seen is Corey Mwamba’s Scrolling Site of Green. Corey uses some creative CSS3 and the :target pseudo-class to create animated tabbed navigation. The demo contains some clever use of CSS3, illustrating how pseudo-classes are often best used in combination with other CSS selectors.

Coreys-scrolling-site-of-green in How To Use CSS3 Pseudo-Classes
Corey’s Scrolling Site of Green.

There’s also an interesting example over at Web Designer Notebook. In it, :target and Webkit animations are used to highlight blocks of text in target divs. Chris Coyier also creates a :target-based tabbing system at CSS-Tricks.

iPhone Form Example
As you’ll see on my demo page, I’ve added a navigation bar at the top that skips down to different sections of the form. We can highlight any section the user jumps to with the following CSS:

:target {
background-color: rgba(255,255,255,0.3);

-webkit-border-radius:
10px;}

3. The UI Element States Pseudo-Classes

:enabled and :disabled

Together with :checked, :enabled and :disabled make up the three pseudo-classes for UI element states. That is, they allow you to style elements (usually form elements) based on their state. A state could be set by the user (as with :checked) or by the developer (as with :enabled and :disabled). For example, we could use the following:

input:enabled {
background-color: #dfd; }

input:disabled {
background-color: #fdd; }

This is a great way to give feedback on what users can and cannot fill in. You’ll often see this dynamic feature enhanced with JavaScript.

iPhone Form Example
To illustrate :disabled in practice, I have disabled the form’s “Submit� button in the HTML and added this line of CSS:

:disabled {
color: #600; }

The button text is now red!

:checked

The third pseudo-class here is :checked, which deals with the state of an element such as a checkbox or radio button. Again, this is very useful for giving feedback on what users have selected. For example:

input[type=radio]:checked {
font-weight: bold; }

iPhone Form Example
As a flourish, we can use CSS to highlight the text next to each radio button once the button has been pressed:

input:checked + label {
text-shadow: 0 0 6px #fff; }

We first select any input that has been checked, and then we look for the very next <span> element that contains our text. Highlighting the text with a simple text-shadow is an effective way to provide user feedback.

4. Negation Pseudo-Class

:not

This is another of my favorites, because it selects everything except the element you specify. For example:

:not(footer) { … }

This selects everything on the page that is not a footer element. When used with form inputs, they allow us to get a little sneakier:

input:not([type=submit]) { … }
input:not(disabled) { … }

The first line selects every form input that’s not a “Submit� button, which is useful for styling forms. The second selects all input elements that are not enabled; again useful for giving feedback on how to fill in a form.

iPhone User Example
You’ve already seen the :not selector in action. It’s particularly powerful when chained with other CSS3 pseudo-selectors. Let’s take a closer look at one example:

fieldset input:not([type=radio]) {
margin: 0;
width: 290px;
font-size: 18px;
border-radius: 0;
border-bottom: 0;
border-color: #999;
padding: 8px 10px;}

Here we are selecting all inputs inside fieldset elements that are not radio buttons. This is incredibly useful when styling forms because you will often want to style text inputs different from select boxes, radio buttons and “Submit� buttons.

Check out our final page.

What’s Old Is New Again

Let’s go back to the beginning of our story and the humble a:link. HTML5 arrived on the scene recently and brought with it an exciting change to the <a> element that gives the CSS3 pseudo-selector an additive effect.

An <a> element can now be wrapped around block-level elements, turning whole sections of your page into links (as long as those sections don’t contain other interactive elements). Whereas JavaScript was once popular for making entire <div> elements clickable, you can now do so by wrapping sections in <a> tags, like so:

<a href="http://www.smashing-magazine.com">
<div id="advert">
<hgroup>
<h1>Jackson’s Widgets</h1>
<h2>The finest widgets in Kentucky</h2>
</hgroup>
<p>Buy Jackson’s Widgets today,
and be sure of a trouble-free life for you,
your widget and your machinery.
Trusted and sold since 1896.</p>
</div>
</a>

The implication for CSS pseudo-selectors is that you can now style a <div> based on whether it is being hovered over (a:hover) or is active (a:active), like so:

a:hover #advert {
background-color: #f7f7f7; }

Anything that decreases JavaScript and increases semantic code has to be good!

Cross-Browser Compatibility

You had to ask, didn’t you! Unbelievably, Internet Explorer 8 (and earlier) doesn’t support any of these selectors, whereas the latest versions of Chrome, Opera, Safari and Firefox all do. Before your blood boils, consider the following solutions.

Internet Explorer 9

Unless you’ve been living under a rock for the last week, you’ll have heard that Microsoft unleashed its latest browser on an unsuspecting public. The good thing is, it’s actually quite good. While I don’t expect people who are reading this article to change their browsing habits, it’s worth remembering that the majority of the world uses IE; and thanks to Windows Update and a global marketing campaign, we can hope to see IE9 as the dominant Windows browser in the near future. That’s good for Web designers, and it’s good for pseudo-selectors. But what about IE8 and its ancestors?

Ie9 in How To Use CSS3 Pseudo-Classes
Internet Explorer 9 is here.

JavaScript

Our old friend JavaScript comes to the rescue. I particularly like Selectivizr by Keith Clark. Keith has put together a lovely script that, in combination with your JavaScript library of choice, adds CSS3 pseudo-class selector functionality for earlier versions of IE. Be warned that some libraries fare better than others: if you’re using MooTools with Selectivizr, then all the pseudo-classes will be available, but if you’re relying on jQuery to do the heavy lifting, then a number of the selectors won’t work at all.

Selectivizr in How To Use CSS3 Pseudo-Classes
Selectivizr.

Keith recently released a jQuery plug-in that extends jQuery to include support for the following CSS3 pseudo-class selectors:

  • :first-of-type
  • :last-of-type
  • :only-of-type
  • :nth-of-type
  • :nth-last-of-type

It’s also worth looking at the ubiquitous ie7.js script (and its successors) by Dean Edwards. This script solves a number of IE-related problems, including CSS3 pseudo-selectors.

So, Should We Start Using CSS3 Pseudo-Selectors Today?

I guess the answer to that question depends on how you view JavaScript. It’s true that pseudo-selectors can be completely replaced with classes and IDs; but it’s also true that, when styling complex layouts, pseudo-selectors are both incredibly useful and the natural next step for your CSS. If you find that they improve the readability of your CSS and reduce the need for (non-semantic) classes in your HTML, then it I’d definitely recommend embracing them today.

You could use two selectors and fall back on a class name, but that would just duplicate work. It also means that you wouldn’t need the pseudo-classes in the first place. But if you did choose to go down this path, the code might look something like this:

li:nth-of-type(3),
li.third { … }

This method is not as flexible as using pseudo-classes because you have to keep updating the HTML and CSS when the page content changes.

If a lot of your users don’t have JavaScript enabled, that puts you in a bit of a bind. Many Web designers argue that functionality (i.e. JavaScript) is different from layout (i.e. CSS), and so you should not rely on JavaScript to make pseudo-selectors work in IE8 and earlier.

While I agree with the principle, in practice I believe that providing the best possible experience to 99% of your users is better than accounting for the remaining 1% (or however big your non-JavaScript base may be).

Follow your website’s analytics, and be prepared to make decisions that improve your skills as a Web designer and, more importantly, provide the best experience possible to the majority of users.

Final Thoughts

It’s hard not to be depressed by IE8’s complete lack of support for pseudo-classes. Arguably, having the browser calculate and recalculate page styles in this fashion will have implications for rendering speed; but because all other major browsers now support these selectors, it’s frustrating that most of our users can’t benefit from them without a JavaScript hack.

But as Professor Farnsworth says, “Good news everyone!� Breaking on the horizon is the dawn of Internet Explorer 9, and Microsoft has made sure that its new browser supports each and every one of the selectors discussed in this article.

CSS3 pseudo-selectors won’t likely take up large chunks of your style sheets. They are specific yet dynamic and are more likely, at least initially, to add finishing touches to a page than to set an overall style. Perhaps you want to drop the bottom border in the last item of a list, or give visual feedback to users as they fill in a form. This is all possible with CSS3, and as usage becomes more mainstream, I expect these will become a regular part of the Web designer’s toolbox.

If you’ve seen any interesting or exciting uses of these selectors out there in the field, do let us know in the comments below.

Other Resources

You may be interested in the following articles and related resources:

(al) (ik)


© Richard Shepherd for Smashing Magazine, 2011. | Permalink | Post a comment | Smashing Shop | Smashing Network | About Us
Post tags: , ,


  •   
  • Copyright © 1996-2010 BlogmyQuery - BMQ. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress