Add flags next to your link using CSS Attribute selectors.

How to add flag next to a link using a keyword in the title. We’ll use the CSS attribute selectors which allows you to target an element based upon its ‘attribute’.

The css attribute selector can be used for any element with an attribute and the possibilities seem almost endless.

At the end, you should get something like this ;

css attribute selector

CSS attribute selector; Documentation .

ex; p[attribut='value'].

Upload the images

You can get those tiny flags here, and upload it in the images folder of your theme for Wordpress.

The CSS

Add the following to your style sheets.

.post a[title$=‘english’] {
display:inline-block;
background:transparent url(images/uk.png) center right no-repeat;
padding-right:20px;
}
.post a[title$=‘french’] {
display:inline-block;
background:transparent url(images/fr.png) center right no-repeat;
padding-right:20px;
}

Explanation;

.post : the class. (wp)
a : the tag link.
title : the attribute.
$ : the selector, means “end with”.
‘english’ ou ‘french’ : the value.

HTML;

Now, you’ ll only have to add ‘english’ (or ‘french’) to the title at the end, like this.

html

It will display the flag next to every links with a title ending by ‘english’ (or ‘french’). That’s it, now it’s up to you to imagine how you could use it. Questions, let a comment.
Doesn’t work in IE6.

Leave a Reply

* Champs requis