Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide HTML form legend using CSS

How can I hide an HTML form legend from visual browsers, using CSS, in an accessible way?

legend { display: none; }

is not an option because, as I understand it, this will 'hide' the legend from screen readers. Other attempts I've made do not remove the legend from the layout - i.e. it continues to take up space.

like image 849
Bobby Jack Avatar asked Jul 08 '09 10:07

Bobby Jack


People also ask

What is CSS legend?

The <legend> tag defines a caption for the <fieldset> element.

What does Fieldset do in HTML?

Definition and Usage. The <fieldset> tag is used to group related elements in a form. The <fieldset> tag draws a box around the related elements.


2 Answers

Added as an answer instead of a comment so I can get more points. :-)

If you really want legends, have you tried putting a span inside the legend and positioning/manipulating that?

I understand this works in IE7 and Firefox...

like image 55
edeverett Avatar answered Sep 30 '22 17:09

edeverett


You can't do this in Firefox because it is a bug in the browser.

You can read more here

Browser Bugs

like image 28
rahul Avatar answered Sep 30 '22 17:09

rahul