<meta> self-closing tags?

Well, yes and no. In XML-based languages, such as true XHTML, you are correct. In HTML, the input tag is closed by the /. The > is content.

I think you’re really confused and/or totally failing to grasp this, as <meta /> and <link /> are REQUIRED if you want valid code when making XHTML just like <img /> – no “good or bad practice” involved… in HTML, /> is invalid markup just as > on standlone tags is invalid in XHTML. The syntax rules are consistent within the doctype you choose.

To clarify, “standalone tags” – that’s META, LINK, IMG, BR, HR, INPUT, ISINDEX, BASE, COL, AREA, PARAM and FRAME. (I think that’s all of them).

If you’re writing XHTML, those tags MUST be closed with />… if you’re writing HTML, those tags should be closed with just >.

Uhm… Isn’t that backwards?? Well, not backwards, but … really wrong?

I thought in HTML the / was an invalid character ignored as an unrecognized attribute (since any element inbetween <tagname and > is treated as an attribute – meaning > is still closing them just like it closes them when the / isn’t there in the first place. I’m pretty sure a forward slash doesn’t close jack in HTML.

<img src=“image.png” alt=“test”>
Open and close. Valid HTML 4, invalid XHTML.

<img src=“image.png” alt=“test” />
Open and close, valid XHTML, invalid HTML but still works because the / is treated as a unrecognized attribute… just as you can type in any amount of fantasy land attributes or tag names and HTML plods on as if nothing is wrong… since that’s one of the ways HTML maintains backwards compatibility.

<img src=“image.png” html5=“bloatedBS” / boxed noclub cluck=“clucked” dyson=“sucks” alt=“test”>

Invalid HTML 4… will still show the image and still parse the recognized attributes (src and alt).

Oh, I finally get it. That was the answer :slight_smile: Thanks.

html5: <img> <meta> <link>
xhtml: <img /> <meta /> <link />

:slight_smile:

ALMOST.

html4: <img> <meta> <link>
xhtml: <img /> <meta /> <link />
html5: mix and match however you want – who cares about formatting rules, clear syntax or trying to prevent people from making mistakes in the first place, just vomit it up any old way – nobody understood the advantages of strict anyways and just wants to sleaze by on as little effort as possible. We want all the gee whiz shiny things now, now, now – who cares what it costs us in the future. It’s the philosophy of most people’s spending – why should coding be any different?

HTML 5 – explosive diarrhea in the swimming pool on a hot July day.

deathshadow60
Actually, in HTML (up to and including HTML 4.01), a / will close the latest tag left open. One example would be the following:

<p/This is a paragraph/
<p/This is another paragraph/
<!-- ignore the following code - SitePoint is having problems with null end tags, it seems ;) -->
>>

This is equivilant to the following:

<p>This is a paragraph</p>
<p>This is another paragraph</p>

The disadvantage is, of course, that you can’t use a / without escaping it.

Since the > doesn’t have to be escaped, unlike the < and the &, this syntax:

<p/> means greater than/

is equivilant to

<p>> means greater than</p>

There are also other SGML shorthand methods. A few examples can be seen in my signature, which is equivilant to:

<p><strong><abbr>HTML</abbr> 4 teh win</strong></p>
<p>In Soviet Russia, website codes you!</p>

Unfortunately, no mainstream user agents actually conform to this. Still, the official HTML validator will correctly validate such shorthand syntax.

Where is that in the specification because

  1. that makes no sense whatsoever, because if so why isn’t the > being shown…

  2. what on earth #DDD would have come up with something so idiotic… Oh wait, is this a SGML syntax thing?

Doesn’t seem to be in HTML 2… doesn’t seem to be in 3.2… doesn’t seem to be in 4.01 – Not sure where you’re getting that from…

Unless you mean the SGML <xxx/content/ construct, which was NOT adopted into HTML to the best of my knowledge. Remember, BASED on SGML doesn’t mean all SGML constructs are valid… if it did:

<img src=“image.png” </img src=“image2.png”>

Would be valid… though it is an excellent example of why SGML is rubbish and why TBL felt the need to make so many changes to it in the first place. :smiley: – though yes, 4.01 tried to be more SGML compliant and for true 4.01 compliance a browser should treat HTML as SGML, but since 2 and 3.2 didn’t have that browser makers really didn’t see the point.

Though since “IMMEDNET” isn’t set, the short / or // for fulltags would be unavailable to HTML as a SGML document, even when “SHORTTAGS” is set to yes.

I dunno, always struck me as the same type of idiocy as opening and closing <?php ?> twenty or thirty times in a fifteen to twenty line PHP file… nonsensical gibberish mess – it’s what moved me away from HTML and to XHTML in the first place. It sure as shine wasn’t for the stillborn (and rightly so) “XML application” nonsense.

In any case, needlessly convoluted mess thanks to it’s SGML legacy should you actually try to follow that.

Question: Does Amaya obey that? I mean, it is supposed to be the ‘reference browser’ and all that with 100% compliance.

The reason why the >'s aren’t being show is that browsers don’t respect the null end tag. This is a rather unfortunate oversight. Not so much in terms of implementation of SGML shorthand in documents, as the few saved bytes means little today, but it prevents easy portability between pseudo-XHTML and other SGML documents.

You can find the reference to implemented SGML shorthand in Appendix B.3.7 of the HTML 4.01 documentation. This is indeed valid in HTML 4.01. I don’t know about earlier versions of HTML (or Amaya, for that matter).

Never noticed that in 4.01 – of course it’s in the appendix and not the normative so easy enough to miss. Be nice if stuff like that was actually in the SYNTAX part of the specification – but of course that would make too much sense.

Though… that’s funny, that’s invalid SGML according to the setting for IMMEDNET, since it’s not stated and defaults to off. Those are only valid when SHORTTAG, IMMEDNET and … gah, one other… are ALL set to on, not just SHORTTAG. It’s FEATURES section in the DTD doesn’t include all the triggers to make that valid…

Strange indeed… though not the first time I’ve seen things in the HTML specification that contradict it’s DTD.

Not to mention that several example contradicts recommendations set forward in the specification. You don’t want things to be too easy, now, do you :wink:

Notice that too, have you? A lot of places it’s like they just copied the HTML 3.2 examples from the long-defunct Netscape reference page without actually checking they were still valid under the new rules or fit the recommendations.

Always good for a laugh.

Though I do notice the nice text in that section in the appendix:

Documents that use them are conforming SGML documents, but are unlikely to work with many existing HTML tools.

So at least they acknowledge the issue. NOT that I see any advantage to using them – quite the opposite in fact.

Teh browsers also left out teh ==short references==
tho looks like teh Wikies took them up : )

##woot tags##

Off Topic:

Is that a thinly veiled reference to one of my old signatures?

“SGML is to XML as L33T is to English”