Markup. Transitional vs Strict

The article will focus on such a seemingly chewed and maimed topic as the validation of a web document according to one of the DTD schemes, which in turn are determined using DOCTYPE .

This topic is not trivial; the advantages and disadvantages of a particular validation method at first glance are not always obvious. Therefore, I decided that mentioning them again would not be amiss.

Recently, many editors and CMS'ki automatically put down DOCTYPE for the document, which in itself is a breakthrough, but unfortunately this is not enough, since often this is the Transitional scheme. Novice developers do not pay due attention to this, and often just do not suspect that they have a choice.

Before moving on to the core of the issue, let's recall what a Transitional scheme is. It was created as a transition, to facilitate the transition from HTML3.2 to HTML4, while preserving the inherited elements and attributes.

Abstracting from a particular language, whether it is HTML or XHTML, the main drawback of Transitional is that the transitional validation scheme allows elements that are responsible for presentational, visual display in the markup.

Modern web development is based on three pillars - markup (html / xhtml / xml), layout (css) and functional with effects (javascript). Moreover, the emphasis here is on a clear separation between them. Markup is a logical division of the document into semantic, semantic components. Style rules in separate file (s) are responsible for the design of the document regarding display devices. The scripts responsible for the interaction between the document and the user, as well as for the effects, are also placed in separate files. Mixing all of these components in one document is considered a bad manners and significantly complicates the life of a web developer and significantly increases the download and display time of a document by the browser.

Unfortunately, we are all far from ideal and all the above problems have always been present. But time does not stand still, markup languages ​​are evolving. Developers move forward with them, but you should not forget about the legacy. Therefore, a transitional scheme was invented that allows you to validate a document containing a mess of elements, styles, attributes and scripts.

All this was done in the hope that conscious developers will move to a new standard, and then pull up their projects. But in this case, unfortunately, the expression " there is nothing more permanent than temporary " fits very well .

And what exactly do?

Use Strict DTD - a strict, unambiguous document validation scheme that was created in order to separate the content from styles and scripts. How to do it? Very simple. In your next project, simply change DOCTYPE to one of these:



By the way, W3C strongly recommends using Strict.

«This is the HTML 4.01 Transitional DTD, which includes presentation attributes and elements that W3C expects to phase out as support for style sheets matures. Authors should use the Strict DTD when possible, but may use the Transitional DTD when support for presentation attribute and elements is required.»

What do you lose by switching to a strict validation scheme:

List of forbidden elements : applet, basefont, center, dir, font, iframe, isindex, menu, noframes, s, strike, u
List of forbidden attributes :
  • Alink denied for body
  • Background not allowed for body
  • The bgcolor
  • attribute is not allowed for body, table, td, th, tr
  • The border
  • attribute is not allowed for img, object , but can be used in table
  • Attribute clear prohibited for br
  • Language not allowed for script
  • Link not allowed for body
  • The name
  • attribute is not allowed for form, img , but can be used in a, button, input, map, meta, object, param, select, textarea
  • Noshade
  • not allowed for hr
  • Nowrap
  • not allowed for td, th
  • Start not allowed for ol
  • Target not allowed for a, area, base, form, link
  • Text not allowed for body
  • The type
  • attribute is not allowed for li, ol, ul , but can be used in a, button, input, link, object, param, script, style
  • The value
  • attribute is not allowed for li , but can be used in button, input, option, param
  • Vlink
  • not allowed for body

    Structural changes : elements a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, q, samp, select, small, span, strong, sub, sup, textarea, tt, var and text cannot be children of blockquote, body, form, noscript . In other words, blockquote, body, form, noscript elements can only have block elements in first level children.

    Failure of the target = "_ blank" attribute for links. Firstly, telling the user how and where to open the link is not beautiful. Secondly, if necessary, this can be done simple way and advanced .

    What do you get?

    • Well-structured markup
    • Clear separation of content from design
    • Possibility of faster and easier work and code support
    • Code Writing Discipline
    • Respect and respect;)

    When to use Transitional? There are two main points. The transition scheme is good when you work with a lot of other people's code, which is not possible to change. A good example is most CMS. In most cases, it is impossible to change their code without getting into the kernel, which automatically excludes the possibility of updates.

    The second point is the use of iframe. If you use iframes in your projects, then it leaves you no choice. Use Transitional.

    In order to facilitate the transition from a transitional scheme to a strict one when marking up a document, think about why this or that element is needed, and not about how it will look.