1
votes

I have an exam, where I will be provided a series of code snippets and asked to determine whether they are Valid or Invalid Strict XHTML1.0. I can't find any rules, or digestible resources online. Can anyone advise if there is a set of checks that I can memorise?

1
you checked w3.org/TR/xhtml1 ? Or does that fall under the category 'indigestible'? It contains all info you need, I think.Erik
If you have to do by hand from a piece of paper, that's a lot of work. Those language specs are large! So... where to begin. You do know the XML syntax? That's rule #1, obviously, well-formed XML. Then there's the valid elements; how about this w3.org/2010/04/xhtml10-strict.htmlMr Lister
You know what, I've been thinking. Maybe the topic itself is irrelevant, maybe they're just trying to find out how good your Google-fu is, by asking about a subject they never covered.Mr Lister

1 Answers

1
votes

The most immediate thing you can and should do is ensure the file is served as application/xhtml+xml. If you are creating a file and don't have access to server-side scripting then you simply need to create a file with a .xhtml extension and application/xhtml+xml via the developer tools in whichever browser you're using.

I highly recommend using Firefox; when you encounter an XML parsing error the whole page will be hidden, it will have a yellow background and display the error, it's line and column numbers in red text. It's extremely useful for quickly addressing malformed XML parsing errors.

Keep in mind that XHTML 1 (HTML4 equivalent) is outdated and I highly recommend using XHTML5. While I've updated my platform from XHTML 1 Strict to XHTML 5 (link in my profile) you will be exceptionally hard pressed to find better examples of stricter code that will adhere to XHTML5.

Also keep in mind that HTML (text/html) is handled by a browser's HTML parser whereas XHTML (application/xhtml+xml) is handled by a browser's XML parser.

An XML parser will catch malformed XML though it will not prevent duplicate id attributes from wreaking havoc in JavaScript (the first `id attribute of two or more identical values will always be targeted).

It should also be noted that XHTML1 defined attributes to have the same value as the attribute name:

XHTML 1

<select>
<option selected="selected"></option>
</select>

XHTML 5

<select>
<option selected="true"></option>
</select>

XHTML5 defines most though not all (e.g. the autocomplete attribute) as having boolean values (e.g. true or false).

Lastly you can have everything completely XHTML1/5 compliant though if the media type/mime is text/html then your page is not XHTML in any form. One of the greatest advantages of XHTML is that is has to be served strictly; strict code can be dependably served loosely though loose code can not be dependently served strictly and I am not talking about doctypes.