Dealing with non-semantic uses of “rel” in RDFa

2019-06-22 10:47发布

I use RDFa to add linked data to my webpage. I also occasionally use the rel attribute in various tags for non-semantic purposes, such as triggering a javascript tooltip. I am wondering the there is something I can do to distinguish the uses.

For instance, I have RDFa around my social network icons like so:

<a rel="foaf:account" alt="twitter" href="https://twitter.com/cboettig"><i class="icon-twitter" rel="tooltip" title="follow me on twitter (reading, discussing)"></i></a> 

<a rel="foaf:account" alt="github" href="https://github.com/cboettig"><i class="icon-github" rel="tooltip" title="follow me on Github (code, research)"></i></a>

Where rel in the anchor tag is used semantically but rel the icon tags is used by twitter-bootstrap javascript to add a tooltip. Magically, in this example, tools such as http://any23.org intelligenty ignore the rel in the icon. However, when encountering a rel="tooltip" in a span element (used to add a tooltip to a button):

<span rel="tooltip" title="switch to dark theme">
   <a onclick="switch_style('dark');" class="btn btn-mini"></a> 
</span>

This creates an mostly meaningless ntriple such as:

<http://any23.org/tmp/> <http://any23.org/tmp/tooltip> <http://any23.org/tmp/> .

Of course it's not a huge problem, but I'm not sure why this happens with the span elements and not the other examples, or how to avoid it.

1条回答
手持菜刀,她持情操
2楼-- · 2019-06-22 11:46

It's always a good idea to avoid non-semantic uses of attributes, especially rel. One way to avoid this is to use a class (perhaps class="tooltip") instead of a rel.

查看更多
登录 后发表回答