October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Are and Closing Tags Optional in HTML or XHTML?

HTML permits omitting certain table end tags only in specified positions. XHTML 1.0 requires them, and the response Content-Type determines whether a browser uses HTML or XML parsing rules.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sometimes in HTML, but not in XHTML 1.0. Current HTML permits omitting </td> and </tr> only in specific positions. XHTML 1.0 requires both end tags because these are non-empty elements. Whether a browser applies HTML or XML parsing rules depends on the response’s Content-Type, not simply on the markup’s doctype or appearance.

When may HTML omit </td> and </tr>?

The WHATWG HTML Living Standard allows omission under defined conditions; “optional” does not mean the tags can be removed anywhere. Its table rules, on a page last updated 29 September 2026, specify:

As an Amazon Associate I earn from qualifying purchases.

  • </td> may be omitted if the cell is immediately followed by another <td> or <th>, or if there is no more content in the cell’s parent.
  • </tr> may be omitted if the row is immediately followed by another <tr>, or if there is no more content in its parent.

These conditions are different: a following cell permits omission of a cell end tag, while a following row permits omission of a row end tag. For the complete rules, see the WHATWG table-element requirements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What changes in XHTML 1.0?

XHTML 1.0 is an XML application, not merely HTML written with stricter-looking syntax. The W3C specification says end tags are required for non-empty elements; td and tr are non-empty elements. Omitting either end tag therefore makes an XHTML 1.0 document not well-formed. The rule appears in W3C XHTML 1.0, section 4.3; XML’s general element syntax is described in the XML 1.0 specification.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

So the answer to “will a browser choke?” depends on how the response is parsed. Under XML parsing, a missing required end tag is a well-formedness error. Under HTML parsing, an omission allowed by the HTML rules is accepted.

Why the response’s Content-Type matters

A browser selects the relevant parsing rules from the response media type. A document served as application/xhtml+xml is parsed as XML; one served as text/html is parsed as HTML—even if its author intended XHTML syntax. W3C’s XHTML Media Types guidance explains this distinction and notes that XHTML delivered as text/html is not processed as XML, so XML well-formedness errors may go undetected.

Check the actual response Content-Type rather than inferring parser behavior from a doctype, an xmlns attribute, or a filename. A page rendering in a browser does not, by itself, prove that the document is valid XHTML.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Could omitted tags explain a table-formatting problem?

Not enough information is available to identify the cause of the formatting issue described in the 28 October 2008 SitePoint discussion. The post did not include the source document, response headers, browser, or a reproducible example. Adding explicit tags may have coincided with a change that fixed the display, but the report does not establish why.

To diagnose a similar issue:

  1. Inspect the response headers and note the actual Content-Type.
  2. Validate the document against the syntax it claims to use: HTML for text/html, or XML/XHTML well-formedness for application/xhtml+xml.
  3. Reduce the table to a minimal example that still reproduces the formatting problem, then check its markup and styles.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should you include the closing tags anyway?

Usually, yes: explicit </td> and </tr> tags make table structure easier to read and maintain, and they are required if the document is served as XHTML/XML. In HTML, they remain valid even where omission is permitted; omitting them is an option only when the specification’s conditions are met.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.