Print

Print


Remember that parsing these tags is probably done with a stack. So <b><i>
pushes a bold tag onto the stack, followed by an italic tag. The proper
closing sequence, </i></b> pops the italic marker off the top (to expose
the bold marker) then pops the bold marker off. OTOH, if you tried to close
the bold tag first, you would be pulling the <b> tag out from underneath
the <i>, which is illeagal in stack-based systems. HTH.

BTW, from a grammatical point of view, there is no reason why all closing
tags couldn't just be written like </> or something similar. That would
mean pop off whatever's on the top of the stack, or equivalently, close
whatever the last opening tag was. Then we wouldn't have to worry about
incorrectly nested tags. But it would probably be more difficult to read
too.

Thanks,
~Caleb