Datasheet
XML — eXtensible Markup Language. This is a generic, text- and tag-based language used to describe data
and is used as the base language for many other languages, including XHTML.
So, XHTML is in fact largely just HTML rewritten with XML rules. These rules are pretty simple, and
most of the time VWD will help you get it right or show you a list of errors and suggestions on how to
fix them.
Always Close Your Elements
In XHTML, all elements must be closed. So when you start a paragraph with <p>, you must use </p> some-
where later in your page to close the paragraph. This is also the case for tags that don’t have their own clos-
ing tags, like
<img> or <br> (to enter a line break). In XHTML, these tags are written as self-closing tags,
where the closing slash is embedded directly in the tag itself as in
<img src=”Logo.gif” /> or <br />.
Always Use Lower Case for Your Tag and Attribute Names
XML is case sensitive, and XHTML applies that rule by forcing you to write all your tags in lowercase.
Although the tags and attributes must be in all lowercase, the actual value doesn’t have to be. So, the
previous example that displays the logo image is perfectly valid XHTML, despite the uppercase L in
the image name.
Always Enclose Attribute Values in Quotes
Whenever you write an attribute in a tag, make sure you wrap its value in quotes. For example, when
writing out the
<img> tag and the src attribute, write it like this:
<img src=”Logo.gif” />
and not like this:
<img src=Logo.gif />
Note that you could also use single quotes to enclose the attribute value, as in this example:
<img src=’Logo.gif’ />
It’s also sometimes necessary to nest single and double quotes. When some special ASP.NET syntax
requires the use of double quotes, you should use single quotes to wrap the attribute’s value:
<asp:Label ID=”DescriptionLabel” runat=”server” Text=’<%# Eval(“Description”) %>’ />
You’ll see this syntax used a lot more in other chapters in this book.
For consistency, this book uses double quotes where possible in all HTML that ends up in the client.
Nest Your Tags Correctly
When you write nested tags, make sure that you first close the inner tag you opened last, and then close
the outer tag. Consider this correct example that formats a piece of text with both bold and italic fonts:
<b><i>This is some formatted text</i></b>
13
Chapter 1: Getting Started with ASP.NET 3.5
87593c01.qxd:WroxPro 1/25/08 9:05 AM Page 13