Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Mysterious bug in the HTML spec (scrimba.com)
8 points by somebee on Oct 6, 2017 | hide | past | favorite | 5 comments


Some html elements are containers, others aren't. <b> can only contain text, so there is a bunch of ignored <b>'s and </b>'s. Then comes the <em> which is followed by an unexpected closing </b>. Use div's or span's if you want to put something inside and have nesting work normally.


All phrasing content is permitted inside <b>, including <em>. See https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Cont...


Keyword there I think is "runs of phrasing content". That means that you can "nest" different tags but not those of the same tag. The nesting <b> inside <b> like op is causing the parser to ignore the depth of nesting of <b> elements and just closes the bold content on first </b>.


It's certainly valid to have some tags inside <b>. How else would you have bold and italic text? I thought you could have all types of tags inside <b>, but it seems something weird happens once you stack more tags of the same type?


is this really something you want to show on hackernews ? why not asking stackoverflow community for this ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: