Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
html5 optional tags
I’ve not really paid attention to optional tags before until looking at this code example.
Offline
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
Re: html5 optional tags
Omit optional tags (optional).
This seems sort of recursive to me. :)
Offline
Re: html5 optional tags
Bloke wrote #301663:
I still kinda prefer matching opening and closing pairs, though. It just feels…
+1
Offline
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
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
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
Re: html5 optional tags
Some XML parsers (e.g. the one used in etc_query
) might dislike it, fwiw.
Offline
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
Pages: 1