Grow your CSS skills. Land your dream job.

The Rules of the Rel Attribute

  • # May 28, 2012 at 10:01 am

    I’m in a situation like this: I have been using the rel attribute as a kind of data storage and a class replacement for the same group element because my blog does not allow attributes other than rel and href (even data-*, especially in the comment form). The problem is that my attributes are not valid for some value (forget about the invalid & signs. I already know what causes it and it did not matter. As the blog that I use is not an open source platform. I focused on the rel attribute definition only).

    I don’t quite understand because as I know the definition/function of rel attributes is just for a relationship clue that commonly used search engines to help find something and will not affect nothing. But this article and other discussion says that the rel attribute in XHTML only allowed to and elements.
    Is the comment from Chris Pratt in the article can not be a consideration?

    … As long as you’re correctly identifying a relationship, you should not be constrained by what has or has not been added to some approved list. Take rel=”lightbox” for example. This is used all over the web to add lightbox functionality to image galleries …

    # May 28, 2012 at 12:40 pm

    Using the rel attribute is kinda a win lose situation. You can use it for stuff like the “lightbox”, but it won’t validate. Not validating isn’t the end of the world though.

    WordPress has a rel attribute hard coded in it that doesn’t validate. Does that mean WordPress is wrong? No, it just means it’s not going to have perfect validation.

    As long as you don’t care about having your site validate perfectly go ahead and use the rel attribute as you see fit. Just don’t go overboard. Only use it if you need to. Most of the time you can get away with classes and id’s rather than rel.

    # May 28, 2012 at 10:26 pm

    Thanks for the reply. As I could not use a class or ID, so I used rel. And I think some of the rel value on my blog is not out of human logic (ex: rel="code", rel="pre").
    I don’t even know if WordPress also has some similar problems.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".