Which DOCTYPE to use?

by 20 replies
23
Hi,

I am using this DOCTYPE, which one is best to use?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
It's an English language site, but occasinally I need Spanish/Eastern European/German characters to be dispalyed...

What would you recommend?
#website design #doctype
  • The doctype deals with what version of html you are using, so you pick the one based on that.
  • Where can I find that information?

    I am coding HTML in Notepad++ and I'm using various HTML codes, so I'm unsure about this thing... honestly: I only started paying attention to this DOCTYPE think about 2 weeks ago...
  • Just use: <!DOCTYPE html>

    It's for HTML 5. Here's a list of tags you can use with each doctype.

    http://www.w3schools.com/tags/ref_html_dtd.asp
  • I used same, some of my client used special character like in denmark language, it's seems no problem.. just include

    Code:
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    you can visit this link

    HTML Codes - Special Characters for Spanish - ASCII Table - Spanish HTML Codes
  • The doctype and the languages (character set) have nothing in common.

    Doctype - as it was said above - refers to the (X)HTML version used in your file.
    For a long time the default WP themes came with XHTML 1.0. Lately they switched to HTML 5.0.

    The encoding, for different languages, is set by one of the meta tags in the <head> section; see above. Use always utf-8 and all the languages, all the special characters will be displayed correctly. (And you won't even need those special characters: just switch your keyboard to another language and you'll be fine - I always have installed on my keyboard 4-5 languages and I never have to use that special characters complication...)
    • [ 1 ] Thanks
  • So, should I still use this one?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    • [1] reply
    • That depends on how your coding the site.
      If it's XHTML like declared then yes.
      If it's HTML5 then no.
      If it's XHTML strict, then no....
      and so on.....

      and just as "Istvan Horvath" stated already....
      "The doctype and the languages (character set) have nothing in common."

      How are you coding the site? Answer that then declare the doctype.
  • I am coding my site manually in Notepad++

    I am using various HTML and CSS codes, didn't pay attention to the HTML 5 or earlier versions. So I'm pretty much using commands, codes I learned, but not sure what version of HTML that is... I didn't know it counts - so long the browsers can read and display it...

    There is no XHTML in my code. Perhaps in 3rd party scripts (e.g. commenting scripts?)... that I add to my pages?
  • You should read up on HTML vs XHTML if you don't know the difference. You are probably coding in XHTML and don't even realize it.


    I would use <!DOCTYPE html> and code for HTML 5. It works with HTML 4 and I believe uses the XHTML standards. Only a few new features (<tags/>) of HTML 5 are not supported by every web browser. IE is the browser that has the least support, but you probably won't be using the <tags/> that aren't supported anyways.

    Read up on HTML 5 here.

    Also, drop Notepad++ and find yourself a better IDE.
    • [1] reply
    • LOL

      Why the hell would you need an IDE for HTML/CSS/JS?

      It's simple text, nothing more...
      • [1] reply
  • Use <!DOCTYPE html> to embrace the features of HTML5, the latest HTML version.
  • I simply use <!DOCTYPE html> ... seems to be fine... only that notepad++ turns it to black color.

    This is not displaying foreign and some other characters:
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />

    (gives me weird question mark characters instead)

    So I turned back to use this:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    Seems to work fine...

    Not sure... should I code like this:

    ;

    For it to appear like this?

    É

    Not sure that all of you can see that, because I did get some wicked characters from other computers.
    • [1] reply
    • That probably means you are using an older version of np++. The very latest, above 6.0, have a problem with no 'edit with np++' in the right click menu. You can get along fine without it by dragging and dropping files on it, but I installed version 5.9.x to get the context menu.

      The only times I had the question mark problems with the utf-8 charset was pasting text from a Word doc. The charset=iso-8859-1 will handle that. I wanted to use utf-8, so I set Word to use the straight quotes instead of the curly ones, and that sort of stuff.

      I don't use Word for anything to do with copy and building now, except for a grammar suggestions and spell check after the page is done.
      • [ 1 ] Thanks
  • for now and for the future please use
    <!DOCTYPE html>

    HTML5 technology is for the future, and the technology itself is never backward.
  • Your "wicked characters" are NOT caused by the right encoding but, most likely, by the improper use of your editor.

    In a similar editor (PSPad) that I use for writing and editing HTML, PHP, CSS etc. files I do have an option to change the encoding of the file itself when writing the code. That's the first step.

    On older computers and older browsers you have to check zillion times that the OS version and the browser both understand different character encoding and can display them. Older browsers tend to not "switch" to the character encoding defined in the head... and then you have the weird idiotic characters.

    Trust me, I was one of the first bloggers writing about multilingual blogging and was involved in many things related translation and correct character encoding, including their display in browsers. I know what I am talking about...

    [Az iso-8859-1 NEM jó a magyar betűknek vazzeg... nem tud hosszú ő-t és ű-t]
  • I tried using this:
    <!DOCTYPE html>

    But the W3 validator gave an error and said something like it cannot read (what was supposed to be HTML 5) and didn't show anything else.

    Apart from that, I think it's the iso-8859-2 that works for Central European languages...

    Tried UTF-8, but again: validator gave me some error, so I switched all back.

    Anyway - I'm more concerned about the DOCTYPE. I have a site 100 % in english, some (few, like 2-3 %) foreign words (city names, peoples' names) in it (that's for charset).

    But this HTML 5 DOCTYPE gives me an error. Hmmm...
  • OK, so I will use the ido-8859-1 and will use a DOCTYPE like this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    As I've understood, the "tranny" is not good, so I'll pick the "strict". Different doctypes gave me different errors.

    As for special characters - which I won't have too many - I will use ASCII...

    I guess this should do it.
    • [1] reply
    • You didn't. I mean you haven't understood anything.

      One can NOT change the doctype arbitrarily and hope for a "better" result.

      If you choose a doctype - you must code the file accordingly!

      There are different rules for different doctypes, and that's the part you - seemingly - don't get. Or don't want to understand...
      Once again, some recommended documentation:
      HTML doctype declaration
      W3C QA - Recommended list of Doctype declarations you can use in your Web document

      BTW, any 'strict' type is always more demanding and leaves less room for bad code - in other words, when picking strict you should know perfect coding!!!

      The validator looks at your doctype and compares your code with the standards for that doctype. Of course, if you change the doctype (which you should NOT do, unless you rewrite the code), it gives you different errors.

      You were already told several times in this thread: the doctype should be based on how you are coding your site/document. But you decided not to listen and trying to "outsmart" the validator. Good luck!
  • An IDE is not a garant for good code...

    Before starting to code a website you should KNOW what is needed.

    Notepad++ and Zen Coding plugin is all I need.

Next Topics on Trending Feed