The first half of this chapter focuses on the use of XHTML and CSS when working in Dreamweaver. Discover why developing in XHTML instead of HTML is a good idea and how to start working in valid XHTML Transitional. Some basics of CSS design are also covered. (From the book ASP.NET Web Development with Macromedia Dreamweaver MX 2004, by Costas Hadjisotiriou, Rachel Andrew and Kevin Marshall, published by Apress, 2004, ISBN: 1590593480.)
Web Standards in Dreamweaver, Part 1 (Page 1 of 7 )
With the launch of Dreamweaver MX 2004, Macromedia moves further toward web standards support and incorporates more features that enable web designers to put best practices to work when developing web sites. Using clean, standard markup and separating content from presentation by way of Cascading Style Sheets (CSS) can make your job as an application developer far easier. For example, if you are creating an application that allows clients to update their own pages, CSS controls how that content is formatted so it is more likely to fit the look and feel of the whole site.
In this chapter, we will focus on the use of XHTML and CSS when working in Dreamweaver. You will discover why developing in XHTML instead of HTML is a good idea, how to start working in valid XHTML Transitional, how to use CSS within Dreamweaver, and how to create a tables-based layout in Dreamweaver using XHTML Transitional. You will also learn how to convert that layout to XHTML Strict using CSS to replace elements that are not allowed in a document with a Strict DOCTYPE, how to create a site with a CSS layout in Dreamweaver, and how to handle older browsers.
Authoring Valid XHTML
This chapter assumes that you are working in XHTML; however, most of the following is equally valid if you are working in HTML because Dreamweaver will add the correct markup. The DOCTYPE specifies which version of (X)HTML you are using.
If you haven’t made the change to XHTML yet, here are some reasons why you might want to make that move:
Cleaner markup: The flexibility that current desktop browsers allow can lead to untidy, sloppy markup. A valid XHTML document can easily be read by traditional browsers as well as other devices (such as PDAs and other mobile devices) that lack the processing power needed to interpret sloppy markup.
Greater platform independence: XHTML’s insistence on clean, structured markup makes it far easier to port documents to different environments. XHTML’s strict nature means it is far more likely to be displayed correctly on all devices.
Accessibility: XHTML’s adherence to strict rules makes it easier for alternative devices such as Braille readers, screen readers, and other assistive technologies to interpret the content and present it to the user in a useful and navigable manner. A valid XHTML document leaves no room for nonstandard markup, which eliminates the chance of anything in the document interfering with its accessibility. Making your document accessible to alternate devices also makes it more accessible to search engine spiders. Clean, correct markup is far easier for a robot to index.
Forward compatibility: There will be no future version of HTML. Browser manufacturers are looking toward the future with new releases, and although it is unlikely that support for HTML will be dropped anytime soon, it is always a good idea to work to the newest standards. By doing so, your pages are far less likely to break when the next versions of the major browsers appear on the scene. As you will see later in this chapter, working with the Transitional DOCTYPE enables you to create XHTML documents that will be displayed properly in older browsers but still validate against an XHTML DOCTYPE.
Learning the rules of XML: XML is here to stay. By writing XHTML documents, you are adhering to the strict rules of XML markup, which will stand you in good stead in the future. Getting into the habit of creating well-formed documents will make creating XML documents for different applications in the future second nature to you.
Integrating with other XML applications: XHTML allows the incorporation of tags from other XML definitions, such as Mathematical Markup Language (MathML), Synchronized Multimedia Integration Language (SMIL), and Scalable Vector Graphics (SVG). This might not seem particularly useful to many designers and developers today, but it is likely to become more important as uptake and use of other XML applications grows. Learning XHTML at this relatively early stage will make your résumé and skills very up to date.
Page load time: Valid XHTML documents load faster because the browser does not need to reinterpret bad markup. HTML is lenient about unclosed tags and improperly nested markup, so it leaves more to the interpretation of the browser. Additionally, HTML’s inherent flexibility encourages sloppy markup, which in turn can add load time onto the page through increased file size. As you move toward creating XHTML pages that follow the Strict Document Type Declaration (DTD), you need to move style and presentation aspects into CSS, thus trimming your pages down further.
Despite the increasing numbers of people with broadband high-speed connections, page-load time is still an important issue. Although writing valid, well-structured HTML will also enable faster-loading pages, XHTML enforces that strictness and prevents sloppiness from creeping in. Dreamweaver MX 2004 makes it very easy to switch from working in HTML to working in XHTML, and there is no reason why the change should be problematic for you. Sites written in XHTML perform just as well in older browsers as HTML 4 sites, so there are no issues with backward compatibility. If you are about to start work on a new site with the help of this book, why not take the plunge and go XHTML!
This chapter is from ASP.NET Web Development with Macromedia Dreamweaver MX 2004, by Costas Hadjisotiriou (Apress, 2004, ISBN: 1590593480). Check it out at your favorite bookstore today.