The eXtensible HyperText Markup Language (XHTML) and Cascading Style Sheets (CSS) are both computer programming languages commonly used in web development. The two languages have different purposes and are complimentary to one another, with XHTML defining the structure and content of a web page and CSS providing style. Each has a different set of rules for programming. XHTML and CSS together can make web sites more efficient and accessible.
XHTML and CSS are two common technologies for website creation and are often used together. The former is generally responsible for the content and structure of a web page, while the latter is used to alter the style and presentation of the page. A paragraph, for example, is defined as a paragraph using XHTML, but the font, color, and size of the text in a paragraph is defined with CSS. Another difference between XHTML and CSS is that an XHTML document can be used on its own, while a CSS file by itself does nothing.
From a programming standpoint, both technologies have different styles, although most web development tools can create both XHTML and CSS. XHTML is a markup language, a type of programming language in which words or letters are “marked” with special symbols to create “tags.” A tag in XHTML define various elements of a web page and reference external content. A <p> tag, for instance, defines a block of text as a paragraph, while the <img> tag references an external image file for inclusion in the page. XHTML’s predecessor, HyperText Markup Language (HTML), also contained tags that defined style elements such as font and text color, but these were removed in XHTML.
Developed to provide web authors with a more efficient method of adding style to their pages, CSS can be applied to HTML or XHTML files. It is a style sheet language that tells a web browser or other piece of software how to present a web page or other document to a user. CSS uses selectors, which can be HTML or XHTML tags as well as custom types of content, and declarations, which declare the style applied to the preceding selector. The CSS code can be placed within an XHTML file or in a separate file that can be reused among many pages of the site.
A combination of XHTML and CSS is in many ways superior to older web development methods. Previously, many HTML tags intended to convey structure ended up being used for layout and style purposes. Under the more recent approach, XHTML and CSS both have clearly defined roles. CSS can also increase a website’s accessibility because different CSS files can be applied to the same XHTML code to transform the way a page or site looks. Web developers can also change the look of a page without changing the underlying code, and search engines can index web pages without having to sort through irrelevant style tags.