What is difference between <pre> and <code> HTML Tag?

Parimal Raj picture Parimal Raj · Apr 17, 2013 · Viewed 59.7k times · Source

How does a <pre> HTML tag differs from <code> html tag.

I have checked on W3Schools page, it seems they are just the same.

If there any major difference between them ?

Answer

gpojd picture gpojd · Apr 17, 2013

Don't go to w3schools. Check the w3c documentation for pre and code instead.

PRE:

The PRE element tells visual user agents that the enclosed text is "preformatted". When handling preformatted text, visual user agents:

  • May leave white space intact.
  • May render text with a fixed-pitch font.
  • May disable automatic word wrap.
  • Must not disable bidirectional processing.

CODE:

Designates a fragment of computer code.