Validating Theme Files


WordPress uses CSS and XHTML to display Web pages. To help ensure consistent behavior from one Web browser to another on all computer platforms, it's a good idea to validate the CSS and XHTML in your theme files. The validation process will either confirm that the files are compliant with W3C recommendations or point out problems that may require attention to achieve full compliance.

Fortunately, there are online tools that will check your CSS and XHTML for you. All you do is visit a Web page, enter the URL you want checked, and click a button. Within seconds, the file is checked and a report appears onscreen.

In this part of the chapter, we explain how to validate the CSS and XHTML in your theme files.

Tip

  • In addition to using the validation services discusssed here, you should view your blog with as many different browsers and computer platforms as possible.


To validate CSS

1.

Use a Web browser to visit jigsaw.w3.org/css-validator (Figure 54).

Figure 54. The CSS Validator at w3.org.


2.

To validate a CSS file that is already online, enter the URI for the CSS file in the Address box of the Validate by URI area. It should be something like http://www.example.com/wp-content/themes/default/style.css or http://www.example.com/wordpress/wp-content/themes/default/style.css, depending on whether you installed WordPress in your root Web directory or in a wordpress folder.

or

To validate a CSS file that has not yet been uploaded to your site, click the Browse button in the Validate by File Upload area. Then use the File Upload dialog that appears to locate, select, and open the CSS file you want to upload. It's path appears in the Local CSS file box (Figure 55).

Figure 55. You can browse to or enter the path for a file on your hard disk.


3.

Click Check in the appropriate area.

4.

A report of problems and potential problems appears (Figure 56). Review the report.

Figure 56. The CSS validator displays warnings as well as errors.


5.

If the report includes any errors, fix them in your CSS. Then repeat steps 1 through 5 again until all errors have been resolved.

Tip

  • Not all items on the CSS Validator's report require action (Figure 56). Some are just recommendations to make your CSS better.


To validate XHTML pages

1.

Use a Web browser to visit validator.w3.org (Figure 57).

Figure 57. You can access an XHTML validator on the w3.org Web site.


2.

To validate a theme file that is already online, enter the URL for the blog page you want to validate in the Address box of the Validate by URL area. It could be any page of your blog.

3.

Click Check.

4.

A report of problems appears (Figure 58). Review the report.

Figure 58. Even if the page looks fine, it might contain errors.


5.

If the report includes errors, fix them in the theme file in which they appear. Then repeat steps 1 through 5 again until all errors have been resolved.

Tips

  • Tracking down errors listed in the report by line number isn't as easy as it might seem. Remember, each Web page for your blog can be made up of several php files. Sometimes it's easier to track down the error by the content that appears with it.

  • In many cases, fixing a single error near the top of the list will have a ripple effect that fixes a bunch of other errors further down in the list. For that reason, it's always a good idea to work out the problems from the top of the list down.


To use a validation feed

1.

Create a validation feed address by appending your site's URL to the end of:

http://www.benhammersley.com/tools/ validate.cgi?url=


Here's an example from Miraz's test site:

http://www.benhammersley.com/tools/ validate.cgi?url=http://miraz.info/ vqs/index.php.


2.

Add the URL to your RSS aggregator.

3.

Periodically check the feed.

  • If no problems are found, there will be no items in the feed.

  • If your home page contains invalid code, you will see one or more items in the feed that identify the error(s) found (Figure 59).

    Figure 59. The Wizz RSS feed reader I added to Firefox shows that a post has problems.


Tips

  • The Safari and Opera Web browsers include an aggregator.

  • The Wizz RSS News Reader extension for Firefox is available from addons.mozilla.org/firefox/424.





WordPress 2. Visual QuickStart Guide
WordPress 2
ISBN: 0321450191
EAN: 2147483647
Year: 2004
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net