Tuesday, July 19, 2011

XHTML

So how do I write XHTML?

Well, here's a quick check list of the important requirements of XHTML and the differences between it and HTML. This is NOT a comprehensive XHTML language reference. Please look here for that.
In these examples some code has been omitted for clarity

All tags, attributes and values must be written in lowercase.

Right:
<a href="www.kilroyjames.co.uk" >
Wrong:
<A HREF="www.kilroyjames.co.uk" >

All attribute values must be within quotes

Right:
<a href="www.kilroyjames.co.uk">
Wrong:
<a href=www.kilroyjames.co.uk>

All tags must be properly nested

Right:
<em>this emphasis just keeps getting <strong>stronger and stronger</strong></em>
Wrong:
<em>this emphasis just keeps getting <strong>stronger and stronger</em></strong>

All XHTML documents must carry a DOCTYPE definition

The DOCTYPE is an intimidating looking piece of code that must appear at the start of every XHTML document, it tells the browser how to render the document.
Rules for the DOCTYPE tag:
  • It must be the first tag in the document
  • The DOCTYPE is not actually part of the XHTML document so don't add a closing slash
  • It should point to a valid definition file called a DTD that tells the browser how to read the document
  • You must write the DOCTYPE tag correctly otherwise your document will explode* (into little pieces of HTML called "tag soup") and be unvalidateable.
* I am, of course, perfectly serious...


There are three types of valid XHTML 1.0 document: Strict, Transitional, and Frameset. If you can get your document to validate with "Strict" then do so, however some legacy tags and attributes aren't allowed in Strict so you can use "Transitional" instead.
Note: you might have a problem getting WordPress to validate as Strict because, as of version 2.6.2, some of the internally generated <form> elements still use the "name" attribute, which is not allowed under the Strict DTD, ie. <input name="my_button" />
Note also that using a Transitional DTD takes most browsers out of "Standards" mode. It is much trickier to get your web pages to look consistent across different browsers when the browsers are not in Standards mode. I'm not going to explain the minutae of the DOCTYPE tag as it gets deeper and more complicated, just know that for best results you should use one of the following, preferably the first one (Strict):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

The HTML tag must contain an XMLNS attribute

You don't need to understand the "XML namespace" attribute, except to know that it is required in all XHTML documents. Here is an example of how to write it:
<html xmlns="http://www.w3.org/1999/xhtml">

Documents must be properly formed with HTML, HEAD, TITLE and BODY tags

In HTML it is possible to write a webpage that contains none of the above tags; in XHTML it is not. The above tags must be included and they must be nested and ordered correctly, as follows (the DOCTYPE has been omitted):
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title></title>
 </head>
 
 <body>
  <p>   
    See how the TITLE must be placed in the document HEAD – the TITLE is considered 
to be a "required child" element of the HEAD.
 Notice that the HEAD must also appear before the document BODY. 
Notice also how both the HEAD and the BODY must be contained
 within the HTML tag. Again, HEAD and BODY are "required child"
 elements of the HTML tag. Finally, notice that this text is 
written within a <p>paragraph</p> tag; in XHTML you may 
not write text directly in the BODY tag without using a suitable 
container tag, such as <p> or <div>.
  </p>
 </body>
</html>

All tags must be closed, even single tags

<p>Mary had a little lamb
<p>It's fleece was white as snow
This code is not valid XHTML as the closing </p> tags have been left out. The following example is correct.
<p>Mary had a little lamb</p>
<p>It's fleece was white as snow</p>
In XHTML even single tags have to be closed - absolutely NO tag may be left open.
<p>
 Mary had a little lamb <br>
 It's fleece was white as snow
</p>
Therefore the above example is wrong because the <br> tag is not closed. To close a single tag like <br> and <hr> you simply add a forward slash before the final bracket, like so: <br /> and <hr /> (the white space is optional). To correct the above example we'd write:
<p>
 Mary had a little lamb <br />
 It's fleece was white as snow
</p>
This is correct XHTML.

Attribute minimisation isn't allowed

In HTML, attributes can be strung together almost like they were keywords, ie. <dl compact>, this is called attribute minimisation. In XHTML that is not allowed, attributes and values must be excplicit, ie.
<dl compact="compact">

ID and NAME attributes

In HTML it was legal to use ID and NAME attributes interchangeably. In XHTML the NAME attribute is formally deprecated and cannot be used. In all cases where you would think to use a NAME attribute you must now use ID instead. e.g.
correct HTML
<input type="submit" name="s" value=" Search " >
and now the correct XHTML version
<input type="submit" id="s" value=" Search " />

STYLE is all in your HEAD

XHTML does not allow STYLE declarations within the body of a document they must be placed in the document HEAD instead.

Entity references

Write all literal ampersands as &amp; or they will be assumed to be part of an entity reference. e.g. &reg; is the entity reference for the symbol ® Therefore M&S is invalid XHTML because &S is not an entity reference, you must write it as M&amp;S.

Conclusion

As was previously mentioned, this is not a comprehensive reference but it should be enough to get you up and running with XHTML pretty quickly. Good luck!

Problems with XHTML

Most people don't realise that to use XHTML properly it must be served using the new MIME TYPE "application/xhtml+xml". A MIME TYPE is simply a description that the web server sends to a browser to tell it what sort of document is coming. For instance a JPG image is sent with a MIME TYPE of "image/jpeg" and an HTML document with a MIME TYPE of "text/html". Sending an XHTML document with a MIME TYPE of "text/html" results in the document being parsed and validated as HTML, not as you would no doubt hope, as XHTML. You must use the correct MIME TYPE if you want to use XHTML otherwise you are simply using non-standard HTML. In order to avoid this problem and output standards compliant code you can use the XHTML to HTML wordpress plugin.

HTML 5

Because of seemingly intractable problems with the development of XHTML (mainly that XHTML 2 is incompatible with previous versions of XHTML and HTML and also the MIME TYPE issue), a competing standard supported by Mozilla (Firefox), Apple (Safari), Opera, Microsoft (Internet Explorer) and some other key Internet players has become the new favourite to succeed the old HTML 4.01 standard.
HTML 5 was passed as a draft recommendation by the W3C in January 2008 and is expected to become a full recommendation within the next couple of years.

HTML to XHTML

What is and what isn't XHTML

WordPress, as a system, is based on documents written in the XHTML scripting language. XHTML 1.0 (which is currently the most widely supported version and stands for eXtensible Hyper Text Markup Language) became a W3C recommendation in the year 2000, and was intended to serve as an interim technology until XHTML 2.0 could be finalized. Eight years later XHTML 2.0 still isn't finished. This document therefore uses the phrase XHTML to refer to XHTML 1.0 only.
XHTML is very similar to HTML as both are descendants of a language called SGML. However, XHTML is also descended from XML, which is a scripting language with much stricter grammar rules than HTML, and XHTML has inherited some of that discipline. XHTML is mainly differentiated from HTML by its use of a new MIME TYPE and the addition of some new syntax rules which are explained below.

Why Should I use XHTML

WordPress prints XHTML from all its internal functions, all themes therefore are now in XHTML and so too are most plugins. So, if you want to use WordPress, you should buckle down and learn some XHTML as that's where it is right now.

What are the differences between XHTML and HTML

If you are familiar with HTML, you will be glad to know that the majority of what you know about HTML is still relevant in XHTML. The main differences are that XHTML forces webpage authors to be more consistent and to write more legible code. There are a few syntax and grammar differences and a few HTML tags have been dropped and, really, that's about it. If you know HTML then you'll be surprised at how easy it is to switch to XHTML, and the new XHTML rules will force you to become a better programmer too!

So how do I write XHTML?

Well, here's a quick check list of the important requirements of XHTML and the differences between it and HTML. This is NOT a comprehensive XHTML language reference

Tuesday, July 5, 2011

What is a Theme?

Fundamentally, the WordPress Theme system is a way to "skin" your weblog. Yet, it is more than just a "skin." Skinning your site implies that only the design is changed. WordPress Themes can provide much more control over the look and presentation of the material on your website.
A WordPress Theme is a collection of files that work together to produce a graphical interface with an underlying unifying design for a weblog. These files are called template files. A Theme modifies the way the site is displayed, without modifying the underlying software. Themes may include customized template files, image files (*.jpg, *.gif), style sheets (*.css), custom Pages, as well as any necessary code files (*.php). For an introduction to template files, see Stepping Into Templates.
Let's say you write a lot about cheese and gadgets. Through the use of the WordPress Loop and template files, you can customize your Cheese category posts to look different from your Gadgets category posts. With this powerful control over what different pages and categories look like on your site, you are limited only by your imagination. For information on how to use different Themes for different categories or posts, see The Loop in Action and Category Templates.

Get New Themes

The WordPress Theme Directory is the official site for WordPress Themes which have been checked and inspected, and are free for downloading. The site features the ability to search by type and style, and offers a demonstration of the page view elements of the Theme.

Using Themes

WordPress supplies a default theme (WordPress TwentyEleven theme) in its distribution for your initial use. You can switch between Themes using the admin panel. Themes that you add to the theme directory will appear in the Administration Panels > Design > Themes as additional selections.

Adding New Themes

Appearance Panel
There are many Themes available for download that will work with your WordPress installation.
If the Theme that you are installing provides instructions, be sure to read through and follow those instructions for the successful installation of the Theme. It is recommended that Theme developers provide installation instructions for their own Themes, because Themes can provide special optional functionality that may require more steps than the basic installation steps covered here. If your Theme does not work after following any provided instructions, please contact the Theme author for help.
To add a new Theme to your WordPress installation, follow these basic steps:
  1. Download the Theme archive and extract the files it contains. You may need to preserve the directory structure in the archive when extracting these files. Follow the guidelines provided by your Theme author.
  2. Using an FTP client to access your host web server, create a directory to contain your Theme in the wp-content/themes directory provided by WordPress. For example, a Theme named Test should be in wp-content/themes/test. Your Theme may provide this directory as part of the archive.
  3. Upload the Theme files to the new directory on your host server.
  4. Follow the instructions below for selecting the new Theme.

Saturday, July 2, 2011

New To WordPress - Where to Start

If you are new to WordPress and you're worried about where to start, you've come to the right place! Here is a very simple step-by-step plan for getting started with WordPress. Please remember, if you need help along the way, plenty of options for assistance are listed in this article. Welcome to the exciting world of WordPress! 

Step One - Read

flowchart
Before you invest your valuable time and energy into installing WordPress, there are some documents you need to read. WordPress is a great product; it's easy-to-use, it's quite powerful, but it isn't necessarily the right software for everyone. Just like building a house, you have to use the right tool for the right job.

Step Two - Make a Plan

Based upon the information you've just read, including instructions on installing WordPress, you should have a list of the things you need, and the things you need to do. If not, make that list now--you'll want to make sure it includes the following information:
The following documents will help you understand more about how WordPress works and how to make a plan for your WordPress site:
It is important to make a plan about how you want to use WordPress on your site. Here are some questions to ask yourself. Make a list of the answers so you can add to your plan.
  • Will you install WordPress in the root directory, subdirectory, or you just want to make a test site to make sure you want to use it?
  • Have you made a list of your site Categories? Understand that WordPress can only order Categories alphabetically by name or by ID (order entered through the Manage > Categories screen), so if the display order of your Categories is important to you, start making your list of Categories.
  • Have you made a list of Pages you may want to add to your site, such as About, Contact, or Events?

Step Three - Install WordPress

With this information and your plan, it's time to install WordPress.

Step Four - Set Up WordPress

With your installation complete, it's time to set up WordPress so it will work the way you want it to work. As you change various settings, it is recommended you view how those changes impact your site by frequently clicking the View Site link at the top of the Administration Screen. Though you may choose to do these steps in any order, your site will cause you fewer problems if you proceed in the following order:
Take time to explore the WordPress Codex site, the official documentation site for WordPress. You'll find helpful information by reading WordPress Lessons, and these helpful documents:

Presentation and Themes

Changing the look of your WordPress website is possible with just a few clicks. Here is a list of resources and information about changing the look of your site with WordPress Themes:
At this point, there may be something about your chosen Theme that is bothering you, or, you really want to get your hands dirty understanding how your WordPress Theme works. These simple guides will help you learn about customizing your WordPress Theme:
If you want to create a new WordPress Theme from scratch, or do major renovations, or even design WordPress Themes for public release, you will need to be familiar with HTML, XHMTL, and CSS. The following documents will get you started:
If you want a custom-made WordPress Theme created especially for you by expert web-designers, it is recommended you search for qualified web-designers on the Internet, or look in your local community.

Adding Plugins

There are many "add-on" scripts and programs for WordPress called Plugins that add more capabilities, choices, and options to your WordPress site. WordPress Plugins do many things, including; customizing the results of your site information, adding weather reports, adding spell check capability, and presenting custom lists of posts and acronyms. For more on how to work with Plugins and where to find WordPress Plugins for your site:

Advanced Use of WordPress

Now that you are familiar with the basic features and functions of how WordPress works, it might be time for you to plunge deeper into the power of WordPress. The links below will expand your familiarity with PHP, HTML, XHTML, and CSS:

Introduction to WordPress Terminology

Terminology Related to Content

Terminology Related to Design

Terminology for the Administrator

History of the WordPress Name

 

WordPress was created by the developers as weblogging or blogging software. A blog, as defined in the Codex Glossary, is an online journal, diary, or serial, published by a person or group of people. Many blogs are personal in nature, reflecting the opinions and interests of the owner. But, blogs are now important tools in the world of business, politics, and entertainment.
Blogs are a form of a Content Management System (CMS) which Wikipedia calls "a system used to organize and facilitate collaborative content creation." Both blogs and Content Management Systems can perform the role of a website (site for short). A website can be thought of as a collection of articles and information about a specific subject, service, or product, which may not be a personal reflection of the owner. More recently, as the role of WordPress has expanded, WordPress developers have begun using the more general term site, in place of blog.

Terminology Related to Content

WordPress Terminology
Introduction
Developers
Blog
Content Management System

Content
Posts
Dashboard
Media
Categories
Tags
Custom Taxonomies
Post Meta Data
Custom Fields
Permalinks
Pages
Custom Post Types

Design
The Loop
Templates
Template Tags
Template Hierarchy
Headers
Sidebars
Archives
Archives (by Category)
Archives (by Tag)
Database
MySQL
Themes
Child Themes
Theme Development
Plugins

Administration
Administration Panels
Links
Link Categories
Registered Users
Roles and Capabilities
Comments
Comments Comments SubPanel
Comment Moderation
Discussion Settings
Spam
Combating Spam

Help
Finding WordPress Help
Troubleshooting
WordPress FAQ
Troubleshooting
WordPress Lessons
WordPress Support Forum
Help with Codex
The term Word in WordPress refers to the words used to compose posts. Posts are the principal element (or content) of a blog. The posts are the writings, compositions, discussions, discourses, musings, and, yes, the rantings of the blog's owner and guest authors. Posts, in most cases, are the reason a blog exists; without posts, there is no blog!
To facilitate the post writing process, WordPress provides a full featured authoring tool with modules that can be moved, via drag-and-drop, to fit the needs of all authors. The Dashboard QuickPress module makes it easy to quickly write and publish a post. There's no excuse for not writing.
Integral to a blog are the pictures, images, sounds, and movies, otherwise know as media. Media enhances, and gives life to a blog's content. WordPress provides an easy to use method of inserting Media directly into posts, and a method to upload Media that can be later attached to posts, and a Media Manager to manage those various Media.
An important part of the posting process is the act of assigning those posts to categories. Each post in WordPress is filed under one or more categories. Categories can be hierarchical in nature, where one category acts as a parent to several child, or grandchild, categories. Thoughtful categorization allows posts of similar content to be grouped, thereby aiding viewers in the navigation, and use of a site. In addition to categories, terms or keywords called tags can be assigned to each post. Tags act as another navigation tool, but are not hierarchical in nature. Both categories and tags part of a system called taxonomies. If categories and tags are not enough, users can also create custom taxonomies that allow more specific identification of posts or pages or custom post types.
In turn, post categories and tags are two of the elements of what's called post meta data. Post meta data refers to the information associated with each post and includes the author's name and the date posted as well as the post categories. Post meta data also refers to Custom Fields where you assign specific words, or keys, that can describe posts. But, you can't mention post meta data without discussing the term meta.
Generally, meta means "information about"; in WordPress, meta usually refers to administrative-type information. So, besides post meta data, Meta is the HTML tag used to describe and define a web page to the outside world, like meta tag keywords for search engines. Also, many WordPress-based sites offer a Meta section, usually found in the sidebar, with links to login or register at that site. And, don't forget Meta Rules: The rules defining the general protocol to follow in using this Codex, or Meta, as in the MediaWiki namespace that refers to administrative functions within Codex. That's a lot of Meta!