Comments on: Legend not such a legend anymore https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/ helping you implement HTML5 today Fri, 01 Jul 2016 15:47:51 +0000 hourly 1 By: Thoughts on new HTML5 elements — Nicolas Gallagher — Blog & Ephemera https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-994 Wed, 16 Sep 2009 15:26:57 +0000 http://html5doctor.com/?p=646#comment-994 […] element may be a fieldset, figure or details element. However, Remy Sharp’s article entitled legend not such a legend anymore shows why it is not practical to use legend for the new elements details and figure – because […]

]]>
By: Aleksey https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-781 Mon, 17 Aug 2009 23:27:03 +0000 http://html5doctor.com/?p=646#comment-781 Updated my solution to include keyboard support. It works in Safari 4, but not Safari 3. Seems to work fine in Firefox too; what exactly goes wrong in Firefox with your’s?

]]>
By: Aleksey https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-765 Sun, 16 Aug 2009 23:47:28 +0000 http://html5doctor.com/?p=646#comment-765 Sorry, small correction: legend isn’t a block element, but acts like one in most browsers when forced to be used inside a details or figure element.

]]>
By: Aleksey https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-764 Sun, 16 Aug 2009 21:49:53 +0000 http://html5doctor.com/?p=646#comment-764 I didn’t implement keyboard yet, but I think I can make it work correctly. I think we can put the ideas together and get something that at least somehow works. I don’t think we’ll have a choice when we start implementing this than to wrap details in a known block level element to be compatible with Firefox (new html 5 block elements don’t prevent the vmoit bug).

Also, there’s a problem with your solution with switching the display for the elements inside the details element which would make it have problems with elements that wouldn’t have a default display of block. The WHATWG recommendations specifies the default look for details like so:

details {binding: details; /* is a replaced element, thus technically has no style by default */}
details > _legend_wrapper {display: block; /* also has the arrow triangle thingy, but I won't write that here */}
details > _contents_wrapper {height: 0; overflow: hidden; /* everything inside details except the first legend element is to be wrapped in a virtual block (hence my div) which is then what has it's style changed when you expand/contract the details. The actual contents of the details stay untouched. */}
details[open] > _contents_wrapper {height: auto; overflow: auto;}

the DOM would then be:

details
..legend
..p the actual details

but what is getting styled would look like this:

details
..block_legend_wrapper (invisible to DOM)
….legend
..block_contents_wrapper (invisible to DOM)
….p the actual details

The legend is already a block element, so I just use that, but I emulate the contents wrapper with a div inside the details element which works, but is visible to the DOM of course.

]]>
By: Remy Sharp https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-753 Sun, 16 Aug 2009 09:35:10 +0000 http://html5doctor.com/?p=646#comment-753 @Aleksey – as much as I hate to rain on your fire, but your solution doesn’t quite work :-( (it looks great by the way) – I released a similar demo last week: http://remysharp.com/demo/details-with-js.html (but I’m still not happy with it – the label element doesn’t have keyboard support in Safari, and Firefox still has general problems with keyboard focus).

Anyway, here’s where it doesn’t quite work: remove the wrapping div from the entire solution, and you’ll see Firefox trigger the vomit bug. Here’s a demo of that happening. Check out the markup delivered to Firefox, then check the rendered DOM (in Firebug), you’ll see they’re completely different. ;-(

Close, but interesting that the vomit bug doesn’t trigger if the details and legend element aren’t a direct decedent of the body element.

]]>
By: Aleksey https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-751 Sun, 16 Aug 2009 06:24:09 +0000 http://html5doctor.com/?p=646#comment-751 I revamped my Fiks.html script and moved it to Google code. It includes the cross-browser solution for the details element and html 5 in general: http://code.google.com/p/fiks-html5/

]]>
By: Aleksey https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-735 Fri, 14 Aug 2009 20:52:03 +0000 http://html5doctor.com/?p=646#comment-735 I’m working on this issue right now, and I have a forward and backward compatible way to make this work, but unfortunately, it does require a little addition markup:

{details}
{legend}{span class=”legend”}Details{/span}{/legend}
{div}
{p}Detailed contents go here. They must be nested in a div unless I figure out a reliable way to move the original contents of the details element into a new div dynamically created. If you can help with that, I will be thankful; it’ll cut down on the extra markup required.{/p}
{/div}
{/details}

Once I am done with my solution, I will post a link to it here.

]]>
By: Andy https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-722 Thu, 13 Aug 2009 15:22:20 +0000 http://html5doctor.com/?p=646#comment-722 Ah, scratch what I said about the Javascript. Firefox doesn’t generate random fieldsets if the figure is contained within a block level element.

]]>
By: Andy https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-692 Wed, 12 Aug 2009 14:51:26 +0000 http://html5doctor.com/?p=646#comment-692 Woah. That’s nuts. I’ve been using figure/legend quite extensively and hadn’t encountered this. I think it’s possibly because we aren’t using the document.createElement trick? Looking at our test pages in Firebug I just see the legend element has been disappeared from the DOM and it’s contents appears as a child of the figure.

]]>
By: Remy Sharp https://stevefaulkner.github.io/html5doctored/legend-not-such-a-legend-anymore/#comment-560 Wed, 05 Aug 2009 11:46:46 +0000 http://html5doctor.com/?p=646#comment-560 @Chris Mahon – looks like your markup was stripped from the comment. None the less:

1. The open=”open” is valid, I suspect you had open=”true” or just ‘open’ as an attribute. It’s boolean, but not in the sense of it should be equal to true or false, it just needs to be present.

2. Firebug is showing me the rendered DOM which is what is being styled. So, the source code is one thing, the rendered DOM is the actual thing we’re interested in, and using Firebug, or the IE developer toolbar, we can see that the browser has changed the DOM to suit it’s parsing rules – hence this whole mess with the legend element.

@Lars Gunther – thanks for testing with the HTML 5 parsing turned on – and you’re right, it’s not going to be on by default until FF 3.5 has died out, ignoring IE for the minute – that’s going to be a long while! Which is what takes me back to using another element other than legend. Sending XHTML is fine, but not suitable for IE, and IE still and will continue to, have majority market – so we, as authors, need a solution that truly does pave the cowpaths.

Regarding the querySelector and querySelectorAll – I expect it to run against the rendered DOM, rather than the source. Keep in mind that this would then break if we modified the DOM, say changing the ID of an element, and ran querySelector – it should query the latest version of the DOM, and not the original source code that was delivered to the browser.

@Adam – the closest I was going by the description in the specs, but I’m no browser vendor, so I wouldn’t like to say! I’m assuming it looks like a normal p element with a triangle to the right that rotates when it’s open (again, this is going by the spec). Either way, without the triangle, it should appear, something like the normal legend + fieldset combo (I think!)

]]>