Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-09-29 09:10:39

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,057
Website GitHub Mastodon Twitter

self closing tags validation

It appears that the w3 validator is becoming intolerant to self closing tags such as <br />, <meta name="description" content="" /> etc. Maybe the time has come to drop the slash in the output of the html5 tag parser, as much I personally find it very semantically correct.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2022-09-29 09:53:58

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,134
Website

Re: self closing tags validation

It is a warning, at the moment.

From one of my pages, link to atom feed in the <head /> with <txp:feed_link />:

Warning: Self-closing tag syntax in text/html documents is widely discouraged; it’s unnecessary and interacts badly with other HTML features (e.g., unquoted attribute values). If you’re using a tool that injects self-closing tag syntax into all void elements, without any option to prevent it from doing so, then consider switching to a different tool.

I personally fully agree that message. The closing / should not be there!


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#3 2022-09-29 11:14:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,399
Website GitHub

Re: self closing tags validation

We can certainly look into removing the closing slash in the parser for HTML elements. Probably need to revisit Textile too.

Not sure where that leaves our Txp: tags. Do we carry on as normal? Or do the same and forbid closing slashes on self-closing tags? That’s going to break a lot of sites on upgrade. Or just throw a Testing/Debugging mode warning for a few big release versions, that encourage people to remove their self-closing tags? And then eventually remove support for them.

I’m easy, whatever the consensus is.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2022-09-29 11:22:28

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,134
Website

Re: self closing tags validation

Not sure where that leaves our Txp: tags. Do we carry on as normal?

Yes. That is (pseudo-)XML. A different world. The output of those tags is what matters to the HTML validator.

The output of my example above is

<link rel="alternate" type="application/atom+xml" title="Atom feed" href="https://domain.name/atom/" />

It is here that the closing / matters (for the validator).

BTW – while testing above, I noticed that theHTML validator now first checks if the site is secure, then proceeds with it is job.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#5 2022-09-29 11:31:54

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,057
Website GitHub Mastodon Twitter

Re: self closing tags validation

Bloke wrote #333926:

Not sure where that leaves our Txp: tags. Do we carry on as normal? Or do the same and forbid closing slashes on self-closing tags? That’s going to break a lot of sites on upgrade. Or just throw a Testing/Debugging mode warning for a few big release versions, that encourage people to remove their self-closing tags? And then eventually remove support for them.

I would leave txp tags as they are:) I might be in a minority, but I do believe that self closing tags makes markup more readable.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2022-09-29 11:47:57

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,057
Website GitHub Mastodon Twitter

Re: self closing tags validation

If you’re using a tool that injects self-closing tag syntax into all void elements, without any option to prevent it from doing so, then consider switching to a different tool.

I really object to this aggressive attitude by a supposedly independent organisation.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2022-09-29 13:23:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,399
Website GitHub

Re: self closing tags validation

colak wrote #333928:

I would leave txp tags as they are:)

phiw13 wrote #333927:

Yes. That is (pseudo-)XML. A different world. The output of those tags is what matters to the HTML validator.

Great, that suits me just fine. So all we may need to do is tweak what the tags output to remove self-closers. That’s comparatively easy. We could go through and edit the markup output where necessary. Many of them will be handled by our meta functions like doTag() and doLabel(), so it’s not too onerous. However, most of those are considered deprecated now. So I’d be tempted to leave them alone.

Under the new UI library in 4.9.0+, this kind of thing is abstracted away to the render() method of each class. There’s a flag (self-closing) that can be set or passed in when constructing UI elements. This will output self-closing variants where necessary but ONLY if the scheme is xhtml. If it’s html5 (the default) then it outputs standard tags.

What this means is that, as we move our internals over to using the new UI library instead of the old functions, it should gradually fix the output of all our tags automatically. We can then decide if we want to drop support for xhtml-style tags and remove it from the library. Or we can leave it in for legacy support reasons and ditch it later.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2022-09-29 15:30:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,057
Website GitHub Mastodon Twitter

Re: self closing tags validation

We can then decide if we want to drop support for xhtml-style tags and remove it from the library. Or we can leave it in for legacy support reasons and ditch it later.

Judging from the general stats I guess we can drop xhtml. We all nevertheless know that many computers in state and local authorities offices are older. It’s a tough choice, but on the positive side, txp will lose a few kbs.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#9 2022-09-30 01:05:58

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,134
Website

Re: self closing tags validation

We all nevertheless know that many computers in state and local authorities offices are older.

Those older computers are much more likely able to parse HTML tags than XHTML tags, unless you serve the latter as text/html, in which case there is no point in using the XHTML format (the closing slash is silently treated as a error, typo, and ignored in HTML parsing mode). And IE up to version 11 has never been able to handle application/XHTML + XML correctly.

PS. well spotted, that zealous quasi missionary message at the end of the warning. I think I have become immune to that kind of language coming from the W3C, and ignore it. I’ve seen too many of them of late.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB