What’s the difference between HTML and XHTML?

XHTML follows XML rules. HTML is just ‘displaying things for web pages’ but XML is a markup language used by various software including RSS feeds, Microsoft Office exports, etc… So XHTML came along with the idea of making the web more readable by tools, by making it compatible with XML.

The main difference is every opening tag needs to be closed, every attribute needs a value, etc.

So you can’t do <br> like in HTML, you need to do <br/> in XHTML even though <br> in HTML doesn’t need to be closed, and you can’t do <input required> in XHTML, you need to do <input required=”required”>. But <input required> would be fine in HTML.

Before HTML5 came out, everyone was into XHTML. then people realised, hold on, websites aren’t really meant to be like this, and now HTML5 is the popular thing, dropping all the XHTML rules.