Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML : Text after empty bold tag also displayed in bold formatting

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.

like image 931
Sambhaji Avatar asked Aug 31 '25 16:08

Sambhaji


1 Answers

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.

like image 57
Nachshon Schwartz Avatar answered Sep 02 '25 04:09

Nachshon Schwartz