Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

documenting div sections, use title attribute?

Tags:

html

xhtml

I'm looking for the most terse way to document sections of my page, e.g. div sections.

Anything wrong with using the title attribute, e.g.

<div title="Payment Area" class="form">
   ...
</div>

?

P.S. In case relevant, I'm using the IntelliJ IDE, but new to its various capabilities, e.g. automatic formatting control and other ways to be able to easily understand sections of my pages.

like image 862
Ray Avatar asked Sep 16 '11 01:09

Ray


People also ask

Can a div have a title attribute?

according to http://www.w3schools.com/tags/tag_DIV.asp, DIVs do have a title property which gives you ability to create tooltips without jquery. In fact, most HTML tags that can be used inside <body> do have title property that can be used for tooltips.

When would you use a title attribute?

The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element. The title attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).

What sort of information is appropriate for use with the title attribute?

Appropriate information to include in a link title can be: name of the site the link will lead to (if different from the current site) name of the subsite the link will lead to (if staying within the current site but moving to a different part of the site)

What is the use of title attribute in anchor tag?

The title attribute is used to provide additional information to help clarify or further describe the purpose of a link.


1 Answers

If an element has a title attribute, most browsers show a tooltip with the attribute’s value when you hover over it. In this case, they’ll show a “Payment Area” tooltip when you hover anywhere over that div.

HTML attributes, in general, have a purpose. HTML has comments for documentation! Try them:

<div class="form"> <!-- Payment Area -->
    ...
</div>

You mentioned that you didn't want the overhead of comments. If you count up the characters (including the required space before the attribute, they're actually the same length:

 title="Payment Area"
<!-- Payment Area -->

(But, I agree, they do look bigger!)

like image 104
s4y Avatar answered Sep 28 '22 09:09

s4y