These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:06 pm Advanced search

Questions on Style Sheets and Conformity

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Questions on Style Sheets and Conformity

Postby RobS » Thu Jan 31, 2008 6:57 pm

In the non-XML HTML 5 syntax, what would be the equivalent of the "xml-stylesheet" processing instruction? Would it be the same as in HTML 4?

The spec says that "UAs conforming to this specification will place elements in HTML in the http://www.w3.org/1999/xhtml namespace, at least for the purposes of the DOM and CSS." Does that mean the style sheets for non-XML HTML 5 documents will need to use namespaced HTML elements, or would they use non-namespaced ones like they do for "well-formed" HTML 4 documents?

On a side note, when you go into a site and find they're using a "well-formed" version of HTML 4 or XHTML 1, that makes it easy to make changes to the site by simply adding the "xml-stylesheet" instruction. If they're using a non-"well-formed" 1997-or-earlier version of HTML, it's much more difficult - and much more costly for the client ... sometimes on the same order as recoding the site, so in many cases they wind up just trying to "fix" the old code. There are some cases where it's easy to convert to well-formed HTML 4 code (by simply adding the missing end tags), but when it's not that simple at least management understands why when you explain that the (non-"well-formed") HTML syntax that their site is using is based on a 10-year-old standard. Will there be any difference in concept of "well-formed"-ness in HTML 5 between the two concrete syntaxes, other than the coding of the end tags?

I see the references to namespace-well-formedness with reference to the XML syntax, but not the non-XML syntax.

I would suggest that it needs to be made more explicit that (at least going forward from the 1999 standards) there is the requirement that all "valid" documents must also be "well-formed" - that is, tags need to be properly closed either with end tags (for example, MSIE prefers "<iframe ...></iframe>" over "<iframe .../>", even in XML documents) or else self-closed ("<img .../>"). Otherwise it's going to seem like the "bastardized" version of HTML coding recognized by some browsers still fits into the various levels of conformity of non-XML HTML 5 documents (not well-formed or valid --> [recognized by some browsers but not well-formed] --> well-formed but not valid --> well-formed and valid).

The spec says that "Void elements only have a start tag; end tags must not be specified for void elements." Since all tags in a well-formed document must be closed, that seems to indicate that void tags in well-formed (but possibly not "valid") HTML 5 documents (both XML and non-XML) would preferably be self-closed ("<... />"), where well-formedness in HTML 4 and XHTML 1 documents could be achieved by adding a separate end tag - and for HTML 4 is probably preferred by browser implementations.

Does heavier reliance on the in-memory DOM indicate that in the future there may also be alternate concrete representations of style sheets? For example, either XSL XML style sheets or some other non-XML style sheet could be applied to the non-XML HTML5 and XHTML5 documents.

Thanks in advance.
RobS
<h6>
 
Posts: 3
Joined: Thu Jan 31, 2008 4:48 pm

Re: Questions on Style Sheets and Conformity

Postby Hixie » Thu Jan 31, 2008 9:29 pm

RobS wrote:In the non-XML HTML 5 syntax, what would be the equivalent of the "xml-stylesheet" processing instruction? Would it be the same as in HTML 4?


Yes. The <link> element with rel=stylesheet.

RobS wrote:The spec says that "UAs conforming to this specification will place elements in HTML in the http://www.w3.org/1999/xhtml namespace, at least for the purposes of the DOM and CSS." Does that mean the style sheets for non-XML HTML 5 documents will need to use namespaced HTML elements, or would they use non-namespaced ones like they do for "well-formed" HTML 4 documents?


Either would work fine. (Not using the namespace stuff in CSS is equivalent to using a wildcard, which is why it would work too.)

RobS wrote:On a side note, when you go into a site and find they're using a "well-formed" version of HTML 4 or XHTML 1, that makes it easy to make changes to the site by simply adding the "xml-stylesheet" instruction. If they're using a non-"well-formed" 1997-or-earlier version of HTML, it's much more difficult - and much more costly for the client ... sometimes on the same order as recoding the site, so in many cases they wind up just trying to "fix" the old code. There are some cases where it's easy to convert to well-formed HTML 4 code (by simply adding the missing end tags), but when it's not that simple at least management understands why when you explain that the (non-"well-formed") HTML syntax that their site is using is based on a 10-year-old standard. Will there be any difference in concept of "well-formed"-ness in HTML 5 between the two concrete syntaxes, other than the coding of the end tags?


There's never been a concept of "well-formed" for HTML (as opposed to XML). I don't really know what you mean by it. HTML has to be conforming, which makes it syntactically predictable.

RobS wrote:I would suggest that it needs to be made more explicit that (at least going forward from the 1999 standards) there is the requirement that all "valid" documents must also be "well-formed"


In XML, that's automatically the case, since one is a subset of the other. For HTML, well-formedness is not meaningful.

RobS wrote:that is, tags need to be properly closed either with end tags (for example, MSIE prefers "<iframe ...></iframe>" over "<iframe .../>", even in XML documents) or else self-closed ("<img .../>").


No, that isn't required in HTML -- in HTML, it's unambiguous that <img> is an empty element, just by nature of it being an <img> element.

RobS wrote:Otherwise it's going to seem like the "bastardized" version of HTML coding recognized by some browsers still fits into the various levels of conformity of non-XML HTML 5 documents (not well-formed or valid --> [recognized by some browsers but not well-formed] --> well-formed but not valid --> well-formed and valid).


Not really sure what you mean. HTML5 defines a parsing model that defines how browsers handle all markup, valid or not.

RobS wrote:The spec says that "Void elements only have a start tag; end tags must not be specified for void elements." Since all tags in a well-formed document must be closed, that seems to indicate that void tags in well-formed (but possibly not "valid") HTML 5 documents (both XML and non-XML) would preferably be self-closed ("<... />"), where well-formedness in HTML 4 and XHTML 1 documents could be achieved by adding a separate end tag - and for HTML 4 is probably preferred by browser implementations.


I don't understand what you mean.

RobS wrote:Does heavier reliance on the in-memory DOM indicate that in the future there may also be alternate concrete representations of style sheets? For example, either XSL XML style sheets or some other non-XML style sheet could be applied to the non-XML HTML5 and XHTML5 documents.


I don't know of any plans to have alternative syntaxes for CSS.
Hixie
<h5>
 
Posts: 10
Joined: Tue Feb 06, 2007 8:21 pm

Re: Questions on Style Sheets and Conformity

Postby SneakyWho_am_i » Mon Mar 02, 2009 12:18 pm

Hixie wrote:
RobS wrote:The spec says that "Void elements only have a start tag; end tags must not be specified for void elements." Since all tags in a well-formed document must be closed, that seems to indicate that void tags in well-formed (but possibly not "valid") HTML 5 documents (both XML and non-XML) would preferably be self-closed ("<... />"), where well-formedness in HTML 4 and XHTML 1 documents could be achieved by adding a separate end tag - and for HTML 4 is probably preferred by browser implementations.


I don't understand what you mean.


I took from it that say he had an empty cell in a table. I'd represent it in html4 like this:
Code: Select all
<td></td>


In XML it's acceptable to draw it like this:
Code: Select all
<td />


I think that RobS was saying that he'd always use two tags to represent the empty element except in HTML5.
Personally I'd not add a closing tag for elements that don't need it. For example the img element should not be represented this way in your markup:
Code: Select all
<img src="" alt=""></img>

because as hixie said, "it's unambiguous that <img> is an empty element, just by nature of it being an <img> element". That may make HTML look very yucky and inconsistent, but it works. The closing tag is implied by its starting tag, so if you wrote a closing tag into your markup you'd be closing an element that wasn't open.

In XML we have to close it and we use the slash of death, but only because if we left it open the XML parser would eat our faces. We don't want that.

I say: If the element can have content (like td) then close it with separate opening and closing tags. This will prevent weird situations like in Webkit where you see a self-closing div tag in an html document and it opens a div but never closes it.
I also say: If the element can't have content (like hr, img etc) then let it be self closing (at least if there's any chance that your document will ever be read by an XML parser) or just write it the ancient and original HTML way (if it can never be XML)
SneakyWho_am_i
<h5>
 
Posts: 13
Joined: Wed Oct 08, 2008 10:50 am
Location: New Zealand


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest