Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-09-21 16:21:36

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

html5 optional tags

I’ve not really paid attention to optional tags before until looking at this code example.

Offline

#2 2016-09-21 19:58:15

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

Re: html5 optional tags

Never knew that was possible. Learn something new every day, thanks. I still kinda prefer matching opening and closing pairs, though. It just feels… right somehow.

The rest of that doc has some sensible advice too, with the exception of the first bit about protocol which was originally thought to be a good idea and is now considered an anti-pattern.


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

#3 2016-09-21 21:11:42

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: html5 optional tags

Omit optional tags (optional).

This seems sort of recursive to me. :)

Offline

#4 2016-09-21 21:22:06

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: html5 optional tags

Bloke wrote #301663:

I still kinda prefer matching opening and closing pairs, though. It just feels…


+1

Offline

#5 2016-09-22 05:32:23

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

Re: html5 optional tags

The example here explains:

This is why the tag can only be removed if it is not followed by a comment: removing the tag when there is a comment there changes the document’s resulting parse tree. Of course, if the position of the comment does not matter, then the tag can be omitted, as if the comment had been moved to before the start tag in the first place.

but i do agree that opening and closing pairs is much clearer.


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 2016-09-22 09:44:20

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,259
GitHub

Re: html5 optional tags

Don’t assume other (non-Google/Alphabet) search engines parse this stuff in the same way. I’m all for bit saving, but if Bing blows up when it can’t parse a <head> properly, then I’ll stick to the old way for now.

Also, there’re no HTML5 DTDs, which is a bit sad.

Offline

#7 2016-09-22 13:35:44

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 553

Re: html5 optional tags

Interesting. Although I like the idea of closing pairs for some tags I do like the idea of being able to do this:

<table>
 <caption>37547 TEE Electric Powered Rail Car Train Functions (Abbreviated)
 <colgroup><col><col><col>
 <thead>
  <tr> <th>Function                              <th>Control Unit     <th>Central Station
 <tbody>
  <tr> <td>Headlights                            <td>✔                <td>✔
  <tr> <td>Interior Lights                       <td>✔                <td>✔
  <tr> <td>Electric locomotive operating sounds  <td>✔                <td>✔
  <tr> <td>Engineer's cab lighting               <td>                 <td>✔
  <tr> <td>Station Announcements - Swiss         <td>                 <td>✔
</table>

Makes HTML tables much easier to understand.

Offline

#8 2016-09-22 13:48:09

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: html5 optional tags

My first experience with HTML was reading “How to learn HTML in 24 Hours” or something like that back in 1995. The rules were really less strict back then.

But I spent so long in the XHTML mindset that I am never going to think leaving tags unclosed is a great idea.

The phrase “Be strict in what you send, but generous in what you receive” continues to apply. If your team is comfortable with that style of markup and the trade-offs then it may be acceptable. If your team prefers clean markup and will be visually inspecting markup most of the time, it is preferable to close tags even when not strictly necessary. – To Close or Not To Close Tags in HTML5

Offline

#9 2016-09-22 14:10:52

etc
Developer
Registered: 2010-11-11
Posts: 5,190
Website GitHub

Re: html5 optional tags

Some XML parsers (e.g. the one used in etc_query) might dislike it, fwiw.

Online

#10 2016-09-23 11:36:21

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: html5 optional tags

gaekwad wrote #301667:

Don’t assume other (non-Google/Alphabet) search engines parse this stuff in the same way. I’m all for bit saving, but if Bing blows up when it can’t parse a <head> properly, then I’ll stick to the old way for now.

That’s what I was wondering too, but the referred code example actually says in red letters — not recommended — for the normal way of doing it. Plus it says to either go All-in! with cutting every optional tag, or not at all. Google hype, of course.

All-in-all it seems like a bunch of silly boolsheet to be needlessly confused with. I’d rather learn the more interesting things coming up with CSS and variable fonts.

Offline

Board footer

Powered by FluxBB