I am showing some content inside div.
<div style="height:200px;width="300px"> somecontent </div>
How can I add cation so that when user takes mouse over div area, message in caption appears.
In the HTML, place a div tag around the image and add a div style attribute. Set the div width to the image width, add a text-align property, add space between the image and caption, then add the text caption.
The <caption> tag defines a table caption. The <caption> tag must be inserted immediately after the <table> tag. Tip: By default, a table caption will be center-aligned above a table. However, the CSS properties text-align and caption-side can be used to align and place the caption.
The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!
You can put divs in < header > as of HTML5, but never in < head >.
The simplest way would be to add a "title" attribute, if you are okay with the browser's default formatting.
<div style="height:200px;width:300px" title="This is my caption">Some content</div>
This is a global attribute, supported in all major browsers.
http://www.w3.org/wiki/HTML/Attributes/_Global
No. According to both the HTML4 and HTML5 specs, the caption element can only appear in a table.
When present, the CAPTION element's text should describe the nature of the table. The CAPTION element is only permitted immediately after the TABLE start tag. A TABLE element may only contain one CAPTION element.
You can instead use a title attribute on your div, or some form of tooltip in JavaScript or CSS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With