SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Dec 12, 2008, 05:58 #1
- Join Date
- Oct 2008
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
<input type="checkbox"> within <legend>
What I want to do is include a checkbox within my legend tag that will trigger a javascript function to toggle the display of the contained content.
Is this a massive semantic faux-pas that I should steer clear of?
There's no reason why I can't place the checkbox within the fieldset instead if necessary.
-
Dec 12, 2008, 06:49 #2
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's quite valid, and I've done it on a few occasions. Perhaps not a best practice from a usability point of view, but I don't think it's something you need to lose sleep over, either.
Birnam wood is come to Dunsinane
-
Dec 12, 2008, 12:27 #3
- Join Date
- Oct 2008
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Dec 12, 2008, 13:09 #4
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Using the label tag like that identifies clearly that the text is the label for the checkbox.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Dec 12, 2008, 17:34 #5
- Join Date
- Oct 2008
- Location
- Banned
- Posts
- 506
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:<legend><input id="chk" name="chk" type="checkbox"><label for="chk">Text</label></legend>
-
Dec 13, 2008, 01:59 #6
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I definitely think you should associate the checkbox with a label, yes. Not only is that of paramount importance for screen reader users; it also offers the significant benefit of increasing the clickable area. I find it really annoying when I have to click the tiny little checkbox square.
No, because XML requires all elements to have closing tags, so you have to use <input/> instead of <input>. But since XHTML is of very limited use for 99.999% of the designer/developer population it doesn't matter. And why in the world would anyone use XHTML Transitional anyway? Transitional DTDs are only meant to be used during a transitional (duh!) phase when you're modernising pre-HTML4 documents.Birnam wood is come to Dunsinane
-
Dec 13, 2008, 15:08 #7
- Join Date
- Oct 2008
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks guys - all very helpful.
Bookmarks