Before Dreamweaver
These are a few general notes on XHTML and CSS for my Macromedia presentation today.
My presentation today really confirmed my belief that before attempting to use Dreamweaver or any other HTML editor it’s important to have a basic knowledge of HTML/XHTML and CSS.
Before the invention of Dreamweaver, FrontPage, GoLive and the other popular web page creation tools, most developers used NotePad or some other plain text editor to create their web pages. Now that we have all of these wonderful HTML editors at our disposal many people feel that it’s not necessary to learn how the underlying code works. In all honesty, I have yet to create a web page in Dreamweaver or any other program without having to manually make changes to the code.
HTML
HTML or HyperText Markup Language is the foundation of the web. HTML pages are actually plain text files that have code or tags that tell the browser how to handle and display the content. These tags specify what kind text is to be displayed in the web browser. Tags are used in pairs; opening tag, the content, and a closing tag. For example, if you want to display a plain paragraph in the web browser the paragraph tag is used like this:
[code lang="xml"]
this is the text that is displayed in the web browser
[/code]
Now if we wanted to make the words “web browser” in the above statement bold we would add some bold formatting tags around just the words “web browser” like this:
[code lang="xml"]
this is the text that is displayed in the web browser
[/code]
If we wanted to take the formatting a step further by applying a different font to the above line of code we would add the font tag like this:
[code lang="xml"] this is the text that is displayed in the web browser [/code]
and then maybe you want to add a little color and size into the mix:
[code lang="xml"] this is the text that is displayed in the web browser [/code]
Now lets add a heading to our page:
[code lang="xml"]A Simple Explanation of HTML
this is the text that is displayed in the web browser [/code]
Now the above code could be written a little simpler in HTML, but this is an actual code snippet taken from a web page created with FrontPage, and I think it illustrates the point I’m trying to make, it serves to demonstrate how structure and formatting has been traditionally controlled in an HTML document. The problem with this at the most fundamental level is that HTML documents that include formatting code like font tags become very cumbersome to edit. In order to change the font in a page you would have to open that page and edit all of the font tags in the document. If you have a very large site you may have to open hundreds of documents just to change the font on the web site.
XHTML
For simplicity sake, XHTML is the next generation of HTML. XHTML controls the content “structure” of a web page, but does not control the formatting. XHTML is essentially stricter than HTML; XHTML has certain rules, like all of the code must be in lowercase, all tags must close, and font and other formatting tags shouldn’t be used. You can learn more about XHTML in this Basic XHTML tutorial.
So instead of having all of those font tags in your document, an XHTML code snippet would look like this:
[code lang="xml"]A Simple Explanation of HTML
this is the text that is displayed in the web browser [/code]
Wow, doesn’t that seem easier?
CSS
XHTML works in conjunction with CSS or Cascading Style Sheets. CSS is used to control the style or formatting of a web document. Instead of using nasty font tags within the XHTML document an external file is created that includes all of the style code for the site. The author then links to the file within the XHTML document. What is so awesome about this is that when you want to change the fonts, font colors, background colors and other style elements of the web site you simply open the one CSS file, make the changes, and the new style rules are applied to all the pages in your site.
So lets look at the CSS we might use instead of all of the font tags in the above example:
[code lang="css"]
body {
font: normal 1em Verdana, Arial, sans-serif;
}
h1 {
font-size: 1.2em;
}
[/code]
By styling the body tag with CSS every paragraph tag used on the XHTML page/site will use the same font and font size. In fact, every tag we use on the page will use that font unless we specify otherwise. We then style the h1 tag so that all of the headings are also consistent, slightly larger, font throughout the site. What we have done is separated the content from the style.
Pulling it All Together
As I’ve mentioned, this is a very simplified model of HTML/XHTML and CSS and does not include all of the code necessary to create an actual page, but I think it’s important to have a very basic understanding of how these languages work on the web before you open Dreamweaver or any other HTML editor. There are a lot of tutorials on the Internet that will teach XHTML and CSS and there are two books that I would recommend to learn more about these languages:
Web Standards Solutions The Markup and Style Handbook
Web Designer’s Reference An Integrated Approach to Web Design with XHTML and CSS

Follow me on Twitter
Subscribe via RSS














