Use of trailing slash at the end of html5 tags /> - Page 1
Forum section: electronics / general

author: Picuino
author_rank: Super Contributor
timestamp: October 29, 2022, 11:25:20 am
content: The W3C html code validation service recognizes as an error that the end of a single tag is terminated with a trailing slash at the end.https://validator.w3.org/The Google page no longer has them in its html code:https://www.google.com/Code:<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="es"><head><meta charset="UTF-8"><meta content="origin" name="referrer"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><link href="/manifest?pwa=webhp" crossorigin="use-credentials" rel="manifest"><title>Google</title>...I recently changed my website to remove the final slashes, but I wonder if that could give any problems.

author: Picuino
author_rank: Super Contributor
timestamp: October 29, 2022, 11:30:51 am
content: Facebook main page (spanish) with w3c validator:Code:Code:<!DOCTYPE html><html lang="es" id="facebook" class="no_js"><head><meta charset="utf-8" /><meta name="referrer" content="origin-when-crossorigin" id="meta_referrer" />...<link rel="manifest" id="MANIFEST_LINK" href="/data/manifest/" crossorigin="use-credentials" /><title id="pageTitle">Facebook - Entrar o registrarse</title><meta property="og:site_name" content="Facebook" /><meta property="og:url" content="https://es-es.facebook.com/" /><meta property="og:image" content="https://www.facebook.com/images/fb_icon_325x325.png" /><meta property="og:locale" content="es_ES" /><link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.facebook.com/" /><link rel="alternate" media="handheld" href="https://m.facebook.com/" /><meta name="description" content="Inicia sesi&#xf3;n en Facebook para empezar a compartir y conectar con tus amigos, familiares y las personas que conoces." /><link rel="canonical" href="https://es-es.facebook.com/" /><link rel="shortcut icon" href="https://static.xx.fbcdn.net/rsrc.php/yb/r/hLRJ1GG_y0J.ico" />...

author: tooki
author_rank: Super Contributor
timestamp: October 29, 2022, 11:38:56 am
content: As you can see, it is NOT flagging it as an error, since it says it’s “info”.The two links in the info message tell you why they recommend against it. So what’s unclear to you?The first link (https://github.com/validator/validator/wiki/Markup-%C2%BB-Void-elements#trailing-slashes-in-void-element-start-tags-do-not-mark-the-start-tags-as-self-closing) says why you might want to use them, and shows an example of why you shouldn’t in some cases.The HTML standard doesn’t require it, the validation recommends removing it, and Google (which has been known to serve a few pages to a few people a day, you know) stopped using it, so why do you think it would cause problems?

author: Picuino
author_rank: Super Contributor
timestamp: October 29, 2022, 11:46:18 am
content: Quote from: tooki on October 29, 2022, 11:38:56 amI thought it might give problems with older browsers. It is best to make the html code as compatible as possible.Anyway, now that Microsoft Explorer has been removed from circulation, it should not cause problems with any modern browser.

author: tooki
author_rank: Super Contributor
timestamp: October 29, 2022, 12:02:52 pm
content: Quote from: Picuino on October 29, 2022, 11:46:18 amThe trailing slash isrequiredin XHTML,prohibitedin HTML4 and earlier, andoptionalin HTML5. So unless your site isXHTML, you can get rid of them. Most browsers tended to be very tolerant, of course. (Also, in both HTML and XHTML, there are parser flags you can set to allow the opposite behavior.)