Monday 22nd of May 2017 09:26:13 PM

CSS Style Guide

XHTML and CSS Validation

Before publishing any XHTML page on the library’s server, you must be certain that it contains only W3C-approved tags and properly authored Style Sheets. The process of Kosherizing your XHTML and CSS is known as validation.

Free online tools

Free online tools make validation easy. Just follow these steps:

  1. Upload your page to the library’s server but do not yet link to it externally.
  2. Visit the W3C Validator (or the HTML the background anywhere in the background of an element, and we can control (to a degree) how it tiles. As you may have already realized, setting an image to be in the center of the document may mean, given a sufficiently long document, that the background image isn't initially visible to the reader. After all, a browser only provides a window onto the document. If the document is too long to be displayed in the window, then the user can scroll back and forth through the document. The center could be two or three "screens" below the beginning of the document, or just far enough down to push much of the background image beyond the bottom of the browser window, Help Validator maintained by the Web Design Group).
  3. Type the URL of the web page you just uploaded into the forms at either of these services.
  4. Wait a few seconds while the validator examines your page.
  5. Fix any errors offline, upload the corrected page, and try again.
  6. Be sure to validate your CSS as well and correct errors (if any).
  7. When all documents validate, you may link to your page from the library’s site. (If you are unable to understand or correct your errors, see the Web Coordinator.)

Validation takes getting used to, but soon the process will become second nature. Essentially it is like receiving the consulting services of a world-class HTML and CSS expert for free.

Understanding Validator Error Messages

Note that the Validators’ error-reporting can be confusing. Sometimes an error in one part of the markup gets reported as an error further down.

For instance, if the validator is coughing on a paragraph tag, and the tag appears to be written correctly, check the markup preceding the paragraph tag. Higher up on the page, you may have forgotten to include a closing quotation mark at the end of a link, or you may have neglected to end an IMAGE tag with a a closing forward slash (/). For some reason, the Validator catches these errors, but reports them incorrectly.

One-click validation

If you tire of typing the validation service URLs, you can install free validation "bookmarklets" in your browser’s Favorites bar courtesy of David Lindquist, an independent web developer.

« XHTML Section Index | Cascading Style Sheets »

the page quicker. 
You can stop text wrapping by including a CLEAR attribute in a line-break tag.  Move your mouse over the image and you'll see the text that's specified in the ALT attribute. The IMG tag's  LEFT and RIGHT ALIGN attribute options wrap the text around the image.  The other ALIGN options font-size -- remember,line-height is set in relation to thefont-size of the element itself, not the parentelement.

Figure 8-61

Figure 8-61. Assigning the line-height property to inline elements

It's important to keep these sorts of things in mind whenyou're trying to do things like add borders to an inlineelement. Let's say you want to put 5-pixel borders around anyhyperlink:

Introduction

The applications that you create with Java and XML will rely on the services provided by your Java XML Parser (using DOM or SAX). The information itself might be stored in a variety of persistence engines (object databases, relational databases, file systems, dynamic websites, etc.). The information however that comes out of these persistence storage engines must be converted to XML (if they are not in XML already). Once this is done, you have to be concerned with the material covered in this document. This document outlines the most popular Java XML application categories that are possible in an environment where data is encoded with XML, where web access is ubiquitous and platform independence is a necessity.

Java Application Layer

All of the code that you write (in your Java classes) might be considered the Java application layer. Other layers are the XML Parser layer, the XML source (that supplies the XML data that is necessary), and the persistence engine (where the data is actually stored and retrieved by the source).

Your code (in the Java application layer) has to make use of the DOM or SAX API and the XML parser in order to access the information in XML documents (that come from your source). The source might be responsible for pulling data from different persistence engines (relational or object databases) and even the web (dynamically generated websites that supply only XML data).

<P STYLE="font-size: 12px; line-height: 12px;">
This is text, <EM>some of which is emphasized</EM>, plus other text<BR>
which is <B STYLE="font-size: 24px;">boldfaced</B>
and <SPAN STYLE="vertical-align: top; line-height: 4px;">tall</SPAN>
and which is<BR>
larger than the surrounding text.
</P>

Since the line-height for the "tall" text is less than its font-size, the inline box for that element is smaller. This will change the placement of theI will take a break from my normal pragmatic approach to getting you (the programmer) started with using XML and Java and just talk about the high level (design level) benefits of this wonderful combination. A good design is important to a good implementation for any system.

XML is structured

When you create your data using an XML editor (that you can write), you can not only input the content of your data, but also define the structural relationships that exist inside your data. By allowing you to define your own tags and create the proper structural relationships in your information (with a DTD), you can use any XML parser to check the validity and integrity of the data stored in your XML documents. This makes it very easy to validate the structure and content of your information when you use XML. Without XML, you could also provide this validation feature at the expense of developing the code to this yourself. XML is a great time saver because most of the features that are available in XML are used by most programmers when working on most projects.

By using XML and Java, you can quickly create and use information that is properly structured and valid. By using (or creating) DTDs and storing your information in XML documents, you have a cross-platform and language independent data validation mechanism (for free) in all your projects!

You might use XML to define file formats to store information that is generated and used by your applications. This is another use of the structured nature of XML. The only limitation is that binary information can't be embedded in the body of XML documents. For example, if you wrote a word processor in Java, you might choose to save your word processor documents to an XML (actually your ApplicationML) file. If you use a DTD then your word processor would also get input file format validation as a feature for free. There are many other advantages to using XML and a file storage format for your applications which will be illustrated later in the chapter.