Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can <caption> tag be used with div?

Tags:

html

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.

like image 286
user123 Avatar asked Nov 25 '13 18:11

user123


People also ask

How do you add a caption to a div?

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.

In which tag caption tag is used?

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.

Can I use a tag as a div?

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!

Can we use div in header?

You can put divs in < header > as of HTML5, but never in < head >.


2 Answers

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

like image 97
Noah Heldman Avatar answered Sep 23 '22 11:09

Noah Heldman


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.

like image 36
j08691 Avatar answered Sep 25 '22 11:09

j08691