I originally taught myself HTML 4.0 a few years ago, but I found it difficult to make the transition to using xHTML with CSS (Cascading Style Sheets). However, due to being involved with a small website I was forced to make sense of it. In this article I will run through the practical implications of switching between the two, in other words what you will need to do to make your HTML work with stylesheets.
Iâ ™m not going to go over the history of xHTML here, but you should take note that there are many â ˜tagsâ ™ that have been deprecated and should be avoided in when using xHTML.
The first important difference in xHTML comes in the form of its syntax. The language is case sensitive, so it is all written in lowercase, no more use of caps! Secondly, â ˜tagsâ ™, or elements to be technical, are now classified into two types: those that contain data, and those that are empty. An example of the former might be a paragraph element, which has a closing tag. That which is in between these two tags is the contained data. For instance, a sentence is understood to be data. An example of an empty tag could be a line break, and is written slightly differently than in HTML 4.0, instead of having a forward-slash just after the opening bracket the forward-slash must be written just before the closing bracket and must be preceded by a space. Other empty types include the image element and the horizontal rule element . The Old Joel on Software Forum: Part 3 (of 5) - Standards :: Im not much of a web expert, but I just spent the weekend learning about HTML4, HTML4.01, XHTML4, CSS 1, etc. Or do you mean the Accessibility standards? http://discuss.fogcreek.com/joelonsoftware3/default.asp?cmd=show&ixPost=102074&ixReplies=25HOME | XHTML 1.0 Strict and the Apostrophe - CSS & Web Design Forum:: Reference #39 or #8217 as we move from HTML to XHTML 1.0 Strict. I've therefore use ' instead of ' to work as expected in HTML 4 user agents." http://www.csschat.com/showthread.php?t=9524HOME |
Another point to bear in mind is that because xHTML is supposed to be compatible across various devices, all images must have alternative descriptions (which means you have to make use of the alt attribute in image elements, itâ ™s no longer just an option). Similarly, youll be making extensive use of the id attribute in xHTML (similar to the name attribute, but used differently - see below).
The biggest hurdle for myself personally was learning the syntax of CSS. There are actually three ways of using CSS, of which one is to create a separate document with a .css extension. This file will contain all the styling attributes of the elements in your xHTML code. You can also place CSS in the â ˜headâ ™ element (using style as an element), or you can embed it into an element anywhere in your code (for this you would use the â ˜styleâ ™ attribute). Using an external file can be useful as changes made to this one document cascade throughout your entire website, hence eliminating the need to change the code on each page. The syntax basically consists of a selector, which can either be an id selector, a class selector or a generic class selector . So, for instance, Ive given an â ˜imgâ ™ element the id MyImg, then I go to my css section/file and create the selector #MyImg {}. Heres where the syntax comes in. the # symbol means that Ive created an id selector, so what follows in the curly brackets will apply to all elements with the id MyImg. An example might look something like this:
#MyImg {
width: 200px;
height: 100px;
border: 0px
}
Notice that I use a colon in place of the equals sign to assign values. If you fail to do this your styles will not be applied. Also, each attribute is followed by a semicolon which separates them. If you do not follow this syntax when using CSS your styling will not come into effect. The last thing you need to know to get started is how to link your external CSS document to your xHTML document. Just nest a element in your head element and youre ready to go. There are plenty of new ways to perform tasks such as positioning in CSS. Have fun playing around with these new possibilities!
My rights and duties- employer asks me to provide testimony in its civil lawsuit
Asian or Pacific Islander?
|