Do you think the differences between HTML and XHTML are generally well-understood?

React really threw a wrench in webdev by making XHTML cool. I think the subtle differences to look out for between HTML and XHTML got lots of attention when it was new, but now that React is so standard and so widely adopted in bootcamps I'm worried that some of the gotchas are getting overlooked.


Did you find this post useful? Show some love!

I never thought I'd see "React" and "XHTML" in the same sentence. I also don't really see how the two are related, per se? I mean, JSX requires self-closing tags to feature the forward slash, as did XHTML, but I don't see how they're related. Perhaps I'm missing something? 🤔

And to be honest, I'd posit the question, "Is HTML generally well understood?"

Too often do devs subscribe to the idea that "HTML is easy." Just throw some divs around in there and call it a day. When in reality, the purpose of HTML is to not only structure our content, but ensure semantic meaning in our UIs as well. Mix this in with the ARIA spec, maybe add a touch device for good measure, and try to convey the correct meaning for folks to comprehend our fancy UIs… it is not easy.

I struggle to come up with the "correct" elements to use often, almost daily in my accessibility assessments. I'm also learning about all the other elements available in the spec. (For example, did you know there's an output element? Bizarre, right?)

What's important to take away here is whatever element is in use, you can (usually) style it for your needs. Whatever the final design calls for, don't base your HTML solely on the look. Consider what's under-the-hood, ie, the semantic meaning of the thing in question so that folks who depend on assistive tech will understand what it is they're interacting with. Then, style as required.

Hmmmm JSX is typically described as more or less aligned with XHTML, but yes it's its own beast. Perhaps I'm leaning too much on the early suggestions from the React folks to think XHTML, and maybe it's not as much of a talking point these days.

As an aside, do you type <br> or <br/> if you use that element in HTML? Just curious.

<br> in HTML, <br/> in React. But really I'd probably just use CSS. 😅

Now that I think about it, pretty sure I only ever use br when marking up an address. 🤔

  Street St.<br>
  P0S 7A1

I typed
for a long time, I still refuse to not type selected="selected" old habits die hard I guess.

This is a classic markdown-attempt-to-write <br/> 😄

I should give one beer for each markdown error :))

JSX is more inspired by an obsolete standard called E4X which in fact uses JS for processing XML. So in that sense it is indeed XHTML, but just because of the fact of processing XML. I don‘t think that the React team focused on XHTML because they thought it should be pushed, but this is just my opinion 😊

I didn't know anyone still used XHTML to be honest. I thought it was a grand experiment that was killed off by people not caring about how it was used and writing pages which broke in Internet Explorer, because Internet Explorer was actually doing The Right Thing.

Mind you, I don't do much front end stuff these days, and React is something that's always on my "to learn someday" pile.

React's JSX is XHTML-like. It's neither HTML or XHTML or JavaScript. It's its own thing, but I think people can get tripped up when their React linter tells them that <div></div> should be <div /> but then they don't fully understand that self-closing tags are not a thing in HTML otherwise. And it's a mistake that won't throw an error but could cause a big mess down the line.

I wish self-closing tags were a thing in HTML(5), because <div></div> and friends are sometimes unnecessarily noisier than <div />. Probably the only feature of XML I like anyway.
I still write a lot of my <meta />s that way, even if not needed, but I run it through tidy, so it makes the HTML the way browsers mostly expect it to be. :shrug:

Honestly, I've been working with HTML for ages and it wasn't until I started learning how to use APIs late last week that I realised there are some actual differences between HTML and XHTML.

Right now, my understanding is it's just a 'dialect' of HTML that's strict in formatting and that it's sometimes used in APIs? Does React actually require XHTML, though?

Edit: Woops! I got XML and XHTML confused :) Hah, maybe that's the issue!


Hey there, we see you aren't signed in. (Yes you, the reader. This is a fake comment.)

Please consider creating an account on It literally takes a few seconds and we'd appreciate the support so much. ❤️

Plus, no fake comments when you're signed in. 🙃

No. I don't even know the difference between the two terms beyond "XHTML have a X"

XHTML must be a well formed XML document. In other words every XHTML document is XML, but not every XML document is XHTML.

In simpler terms - "well formed" means all the tags need to close (or self close) and all attributes need to be in double quotes.

The other difference is that for an XHTML document to be valid it must to conform to the XHTML schema.

This was important when it was thought XML was so important it would eventually take over the world and so naturally it followed that the solution to every problem had to be more XML.

Fortunately the world saw sense before this ever became a reality.

I know I don't fully understand the difference. But they're the same in the sense that your code might not work in your target devices and then you tweak it until it does work.

I randomly try

until one works.

Let's see who will figure it out.

Classic DEV Post from Aug 10

How do you convince a client to a static website?

How do you convince a client to a static website? What are your favorite players? Do you have any tricks or tips you want to share?

Follow @starbist to see more of their posts in your feed. is now open source!
View Announcement Post View GitHub Repo
Ben Halpern
A Canadian living in New York, having a lot of fun cultivating this community! Creator and webmaster of
More from @ben
Does your team write code tests for front-end code?
#discuss #webdev #javascript
What are some good questions for a "State of the Web" survey?
#webdev #discuss
Trending on
Fail Mail #1: Failing at Git Publicly
#webdev #javascript #career #productivity
You deserve better clients, maybe I can help!
#career #webdev #discuss
BxJS Weekly Episode 24 - javascript news podcast
#javascript #node #podcast #news
NetFlix clone web app template (PWA)
#showdev #javascript #html #zuix
Top 33 JavaScript Projects on GitHub (August 2018)
#javascript #opensource #programming #webdev
A New Vue On JavaScript30 - 02 JS and CSS Clock
#anewvueonjs30 #vue #javascript30 #javascript
How I learn code on internet and get my first job?
#react #showdev #beginners #javascript
Why haven't you gone to a development conference?
#discuss #webdev #conferences