General > General Technical Chat

Use of trailing slash at the end of html5 tags />

(1/1)

Picuino:
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>
...

--- End code ---

I recently changed my website to remove the final slashes, but I wonder if that could give any problems.

Picuino:
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" />
.
.
.

--- End code ---

tooki:
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?

Picuino:

--- Quote from: tooki on October 29, 2022, 11:38:56 am --- so why do you think it would cause problems?

--- End quote ---

I 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.

tooki:

--- Quote from: Picuino on October 29, 2022, 11:46:18 am ---
--- Quote from: tooki on October 29, 2022, 11:38:56 am --- so why do you think it would cause problems?

--- End quote ---

I 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.

--- End quote ---
The trailing slash is required in XHTML, prohibited in HTML4 and earlier, and optional in HTML5. So unless your site is XHTML, 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.)

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod