Author Topic: Use of trailing slash at the end of html5 tags />  (Read 1171 times)

0 Members and 1 Guest are viewing this topic.

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: es
    • Picuino website
Use of trailing slash at the end of html5 tags />
« on: October 29, 2022, 11:25:20 am »
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: [Select]
<!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.
 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: es
    • Picuino website
Re: Use of trailing slash at the end of html5 tags />
« Reply #1 on: October 29, 2022, 11:30:51 am »
Facebook main page (spanish) with w3c validator:




Code:
Code: [Select]
<!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" />
.
.
.
« Last Edit: October 29, 2022, 11:33:36 am by Picuino »
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 14901
  • Country: ch
Re: Use of trailing slash at the end of html5 tags />
« Reply #2 on: October 29, 2022, 11:38:56 am »
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?

 

Offline PicuinoTopic starter

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: es
    • Picuino website
Re: Use of trailing slash at the end of html5 tags />
« Reply #3 on: October 29, 2022, 11:46:18 am »
so why do you think it would cause problems?

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.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 14901
  • Country: ch
Re: Use of trailing slash at the end of html5 tags />
« Reply #4 on: October 29, 2022, 12:02:52 pm »
so why do you think it would cause problems?

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


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf