Mark-up languages – XHTML and HTML

XHTML is an XML language

there are different versions of the mark-up languages for web pages. Today, the most used mark-up language is XHTML (X derives from the word eXtensible), a redefinition of the HTML language based on the grammar of the broader mark-up language XML (eXtensible Mark-up Language). Compared to older versions, this means three things when it comes to the XHTML language:

  1. The element tags are written in small letters
  2. All elements must be ended: a start tag must always be followed by and end tag at some point. 
  3. The mark-up must be correctly formulated and faultless: e.g. elements may not overlap. You can read about checking for flaws in the mark-up on the page about validation.

Semantic mark-up

Separating the mark-up describing the page structure from the description of the layout is a larger change with XHTML. The correct kind of XHTML code is semantic; the code only contains tags that describe the structure of the text. In practice, this means that e.g. heading in XHTML should only be marked by heading tags, not with e.g. bold writing or another font size. Paragraphs should also be delineated inside p elements rather than a double forced line break (the mark-up for a line break is <br/>.

XHTML does not contain colour definitions or font changes, either, since the layout should be defined with separate CSS style sheets (Cascading Syle Sheets) when making a web page with XHTML. The style sheets are used to define element features (such as font size and colour) instead of encoding them on the web page. The styles can then be stored in a separate style file. 

There are many advantages with semantic mark-up: 

  • Semantic code is clearer and easier to understand and update than mark-up that concentrates on layout. It is also easier to reuse the code. 
  • Since layout and structure are separate entities, it is easy to change the layout with the CSS or update the contents of the page without disturbing the other. You can also create different page layouts for different media (computer screen, paper printout, mobile phone screen) without having to go through the extra work of copying the contents. 
  • In future, more and more devices will contain web browsers. A web page based on a structured code will work well in these appliances that may not be able to show very complicated layouts or frames, or it may not be technically possible to show them. 
  • Semantic mark-up is easier for software to read and manage, and e.g. conversion into other presentation formats can be automated.