Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting a DOCTYPE for HTML 5 + all browsers

I'm using some HTML5 features on a web page and wondered what the best DOCTYPE is. Currently, this is the DOCTYPE and XMLNS:

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

Should I use the new HTML 5 DOCTYPE?

<!DOCTYPE html>

Will older browsers (IE7, FF 2.x) recognize and render the page correctly? What's the best practice in this situation? Thanks.

like image 927
Alex Avatar asked May 24 '10 18:05

Alex


People also ask

Which DOCTYPE is correct for HTML5?

Correct Option: Ddoctype html>, doctype is the very first thing to write in HTML5.

Are there changes to DOCTYPE for HTML5 what browsers support HTML5?

The only thing that such a doctype change will affect is validation. Other than that, the doctype declaration only affects browser mode (quirks / almost standard / standard), and XHTML 1.0 and HTML5 doctype have the same effect in this respect. If you don't use a validator, there is no reason to change.

Is DOCTYPE HTML required in HTML5?

All HTML need to have a DOCTYPE declared. The DOCTYPE is not actually an element or HTML tag. It lets the browser know how the document should be interpreted, by indicating what version or standard of HTML (or other markup language) is being used.

How many different type of DOCTYPE are defined in HTML5?

In HTML version 4, there are three types of DOCTYPES can be used: strict,transitional and frameset. In this tutorial, we will discuss all these categories with adequate examples to help you to understand how to declare a doctype in an HTML page and how a valid HTML page looks like.


1 Answers

Yes, older browsers will work fine. The reason "<!DOCTYPE html>" was chosen in HTML 5 is because it is the smallest a doctype can be and yet still trigger standards compliance mode on those browsers you mention.

like image 149
ChrisD Avatar answered Sep 30 '22 17:09

ChrisD