I am trying to understand why browser behaves like this.
I have following text in html document.
<html>
<body>
This is Sample Text. <B/>Text after empty bold tag.
</body>
</html>
If I view this document in browser, it is displayed as shown below.
This is Sample Text. Text after empty bold tag.
Why is this happening? Afterall, I did not mark any text as bold.
You need to write valid html code for this to work correctly with opening and closing tags. So you would need to write an opening tag (<B>
) before the text you want in bold and a closing tag () after the text.
<html>
<body>
<B>This is Sample Text.</B>Text after empty bold tag.
</body>
</html>
Notice that in your example you are using <B/>
which is neither a valid opening or closing tag but which may be interpreted as an opening tag in certain browsers.