Combining the Worlds of HTML XHTML and CSS

an article added by: Gregory F at 06132009


In: Root » Computers and technology » HTML XHTML and CSS » Combining the Worlds of HTML XHTML and CSS

French Spanish Portuguese Italian German Japanese Chinese Korean Russian Arabic

There are many different elements going on behind the scenes of a website, and the common techno-speak of HTML, XHTML and CSS are probably all familiar to most users. For someone looking to find their way into coding a website the knowledge of the terms may be there, but what do the terms offer beyond the names? How do you start to make a choice of which code to use where and for why?

Whether it is in HTML or XHTML, scripting a website and combining CSS, is a challenge that can bring great rewards when the site you are building finally goes live. With the HTML, XHTML and CSS all in place everything can look great. All of the pictures will be in position, all of the headings will be displayed alike and all of the content text will flow in a perfect pattern of formatting. This will all be down to how well you have managed to script your pages with HTML, XHTML and CSS.

Standard practice for designing web pages with a coding language, predominantly HTML and then later XHTML, was to manually code every bit of information into the HTML file. Every time, for example, a heading appeared in HTML code, then it would need its own set of formatting codes. What size text, whether it is to be bold, italic or underscored all required HTML tags. Without CSS, the same HTML or XHTML code could be repeated time and time again through the entire pages of the website, just to make everything uniform. An easier format was developed to make life just that little bit easier, and it was called CSS. Now scripting with HMTL, XHTML and CSS combined makes for a more efficient process.

CSS, which stands for Cascading Style Sheets offered a much better solution to the problem of editing design in script. Scripting with HTML and XHTML could prove to be a long winded design process. Imagine developers having page upon page of scripted HTML language for a website and then have to go through to change every instance of colour for subheadings, for example. The expense of time and money doing that could be extensive. Putting to work CSS within the website, eliminates the need to trawl through pages of HTML and XHTML, as CSS sheets can do that entire process from its one file.

With CSS all of the website's recurring styles of how HTML, XHTML are displayed, can be stored in one CSS style sheet. This a immense time saver. All of the coding information within the CSS can be removed from the HTML or XHTML code itself, or simply not get implemented in the first place.

The cascading part of CSS, means that there is an order of precedence of how a web browser reads multiple CSS sheets or rules. The CSS rule or sheet which is at the top of the order will be used first when the browser reads it, so it knows how to display the design elements of the pages, whether they are in XHTML or HTML.

CSS is compatible with all browsers now, and has become something of a standardised format alongside HTML and XHTML. It is extremely useful for small networks of similar websites to be maintained quickly and easily. CSS is fully customisable and workable whether you are scripting with the more familiar HTML or its new and improved form of XHTML.

What is the difference between HTML and XHTML? They are basically two elements which have come together over time. The first element, HTML 4, is a mark-up, or scripting language which is used for web design. All the elements for text and document display are contained in this HTML 4 script. It is this language which has grown and developed into the Hypertext mark-up language (HTML) as well as elements of multimedia and document display.

XML however, was created as a mark-up language which was intended to cut out some of the more difficult and confusing aspects of HTML. What XML did for HTML coding, CSS did for style management. It made everything so much easier to work with. With these two elements combined, XHTML maintains all of the great uses of HTML, but is more workable because of its extensibility.

Extensibility is the X-factor in the XHTML. There has always been a problem with how pages have been displayed across different browser. Because of the HTML tags in the code, different browsers, of which now there are many, would display elements in a different way. The only way to get around this problem was to leave out those problematic tags from the HTML code or CSS sheet altogether, create duplicate pages which had been scripted differently for different browsers, or leave things as they were and hope nobody would notice.

Thankfully XHTML overcame the problem. By using a XHTML module, you can use any tag within your HTML code and CSS sheet and be safe in the knowledge that things will be displayed properly, whichever browser is being used to view the HTML or XHTML page.

While XHTML and CSS have made an impact on the way that web pages are being developed, the more familiar HTML is still going to be around as well. The rules are a little stricter in XHTML but the rewards are great and provides that extra functionality. Cleaner code, whether it is in XHTML, HTML or CSS, will allow pages to load that much faster and let you side step display problems.

Because browsers can be a little lazy, for want of a better word, in how their interpret HTML code, there is simply not that leeway with XHTML. XHTML validators can provide an efficient solution to any problem, by highlighting coding errors. It is always worth running any XHTML pages through one before trying to go live.

Conversion of old HTML pages into XHTML is not too difficult a process, but there are a few simple rules to follow, like nesting tags and using lower case, as XHTML is case sensitive. But with the elements all coming together, XHTML, HTML and CSS can make you web pages stand out proudly on any browser, any where.

legal disclaimer

Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.

related articles

1. XML and CDATA
Processing instructions XML also enables developers to pass information to the application through processing instructions (often called PIs). Processing instructions use a similar syntax to the XML declaration, although the rules for them are much less strict. Processing instructions begin with <? and end with ?>, but the developer generally dictates their contents. The first bit of text before a space appears in a PI is called the target. The target must start with a letter, unde...

2. lang Internationalization
Internationalization: xml:lang and lang Internationalization (often abbreviated i18n because 18 characters appear between the i and the n) gets a significant boost with the shift to XML primarily because of XML's use of Unicode as the underlying character model. While not every document needs to encode Chinese, Cyrillic, Arabic, and Indian characters, Unicode makes it possible for all of these forms to exist within a single document. In addition, XML and XHTML allow for the possibility of other e...

3. Anatomy of an XHTML Document
The transition from HTML to XHTML will come with a fair number of bumps. While later chapters introduce tools to help you get past those bumps – and figure out where they come from – this chapter examines what's going to change and demonstrates a few strategies for handling those changes. Along the way, we visit the ghosts of browsers past and explore problems that exist in current browsers. In turn, you discover how prepared and unprepared various tools are for XHTML. Note Som...

4. Converting to strict HTML and XHTML
Converting to strict HTML You start out by declaring your intentions to use the strict HTML 4.01 DTD by putting the appropriate DOCTYPE declaration at the head of the document: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Now the first section of the document, including the HTML opening tag and the HEAD element and its contents, is fine except for one line. The SCRIPT element no longer supports a LANGUAGE at...

5. Reading the XHTML DTDs A Guide to XML Declarations
Reading the XHTML DTDs: A Guide to XML Declarations Although the W3C has long had document type definitions (DTDs) for HTML, few developers actually use those DTDs as a foundation for learning HTML. XHTML 1.0 simplifies those DTDs with the slightly friendlier XML syntax – they previously used SGML's more complex syntax – and the increased emphasis on validation may lead developers to explore them more closely. Making good use of XHTML 1.1 requires some level of ...

6. Defaulting attribute values XHTML DTDs
XML 1.0 also provides a set of tools for specifying what happens if an attribute isn't declared within an element. Four different possibilities exist, including "the attribute just isn't there"; "the attribute must be there, period"; and "the attribute has this value, period." You already have seen a few uses of these choices in the preceding declarations. In the img element, for instance, the src and alt attributes are required (#REQUIRED); meanwhile, most of the rest of its attribute content is optio...

7. Exploring the XHTML DTDs
Exploring the XHTML DTDs Choosing Your DTD XHTML 1.0 provides three DTDs that describe different sets of XHTML elements and reflect the three choices provided in HTML 4.0: strict, transitional, and frameset. The probably the one that the W3C would like to see developers adhere to, but transitional DTDs reflect the reality of HTML usage much more accurately. Appendix A lists the in the three different DTDs, along with notes regarding attributes. To identify the DTD for a ...