| Getting WordPress Blogs to Validate as XHTML |
|
|
|
| Saturday, 09 December 2006 | |
|
I really like WordPress. It's a great blog. I also like my HTML pages to validate, and I like XHTML. "Now, how do you get your WordPress blogs to validate as XHTML?", you might ask. I thought you'd ask! Validate, then CorrectFirst thing first: validate your pages at the W3C Validator, so you can get a nice long list of the juicy errors you'll need to fix. If you write clean markup, you shouldn't have many. Writing Valid XHTMLIt all starts with your WordPress theme's template. It must be written using XHTML. If your template is not XHTML, you'll either need to find a version of it XHTML, convert it to XHTML yourself, or choose a different template that is written in XHTML. If you're interested in having your Wordpress blog validate as valid XHTML, then you probably already know this: YOU need to write valid XHTML in your posts. Basically, escape all special characters and close and nest all tags properly. There are tons of books and online tutorials on writing XHTML. If you have any specific questions, feel free to post them on our forums. Specify the Character SetOne important part often overlooked is specifying a character set and also saving the document in the proper file encoding. We'll look at file encodings in a minute. Now, regarding character sets: for an XHTML document served up as HTML, which is how most Web servers will serve it, the character set should be specified using a meta element, like this:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Note that I specified the charset as UTF-8, which is the recommened character set for XHTML. You can also use the Western character set iso-8859-1. For English, French, Spanish, and German documents (not sure about Italian and other Western European languages) the two#mdash;Western and UTF-8—are virtually identical. If your HTML has other languages, such as Japanese, you will want to figure out which character set and file encoding to use. It can get complicated. For example, for Japanese, you can use ISO-8859-1 as your character set if you use Shift-JIS as your file encoding. Again, if you have questions/issues, feel free to post them on our forums Saving the File using the Correct File EncodingLike I said earlier, the western character set is similar to the UTF-8 character set, if your document is in English or other Western European language. The same holds true for file encodings. The file encoding for the Western character set (ISO-8859-1) is called ANSI. ANSI is the file encoding; ISO-8859-1 is the character set. Confused? Goooooood ... No, really, it's easy, just a bunch of jargon. The character set are the characters you use when writing, kind of like the alphabet. Humans read character sets. But computers read file encodings: the bytes. The file encoding is how the file's bytes are saved, the order. That's all you need to know. To check your file's file encoding, open it in Notepad. Then do Save As. Note the File Encoding drop down. It probably has ANSI selected. Click it and you'll see other File Encodings you can choose, like UTF-8. If your document is XHTML, choose UTF-8 and save over your original. Now your document is saved in the UTF-8 file encoding. Fixing the <ADMINNICENAME> Validation ErrorWhen validating If you get the error <ADMINNICENAME> that means you have not given yourself (the admin of your blog) a Nickname. Go to Users and update your admin profile by filling the Nickname field. Then save the change and go back and choose a name from the dropdown for Display name publicly as. ConclusionI hope you liked this article. If so, check out my blog, mitchwilson.net/blog. Also, here's a handy page on WordPress.org, Validating a Website. |
|
| Last Updated ( Saturday, 09 December 2006 ) |
| Next > |
|---|










