开发者

Which HTML element makes the most sense for code annotation?

开发者 https://www.devze.com 2023-03-30 23:32 出处:网络
I\'m working on a web app that has code listings. Certain lines of code have notes attached to them (think comments, but not inline code comments - more like an author explaining something).

I'm working on a web app that has code listings. Certain lines of code have notes attached to them (think comments, but not inline code comments - more like an author explaining something).

When a user hovers over the footnote type indicator, a tooltip will display the comment.

Example code on jsFiddle

Now the questions

  1. What element would make the most sense to wrap the comment indicator in? I toyed with the idea of <mark>, but I get the feeling that's a stretch. Somebody suggested the <object> tag could actually make sense. Again, not sure.
  2. Is there an element that the actual footnot开发者_JS百科es (we're calling them annotations) should be wrapped in?

Any insight would be greatly appreciated.


I was thinking that <aside> might be useful, but probably a footnote pattern is really the closest match.

Wikipedia uses <sup id="cite_ref-N"><a href="#cite_note-N">N</a></cite> for the indicator and <li id="cite_note-N">Note</li> for the note. You could do worse than follow that.

0

精彩评论

暂无评论...
验证码 换一张
取 消