Doubt about DOCTYPE and HTML tags

Asked

Viewed 473 times

1

For many years I’ve been using these tags at the beginning of my pages:

<!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">

That code I inherited over time from many years ago and I always kept in the pages, and I never had any problems.

Today I came across an alert message on the IE console (Windows 10, IE11):

HTML1524: HTML5 DOCTYPE inválido. Convém usar o formato interoperável "<!DOCTYPE html>".

After all, I should delete this line with !DOCTYPE or change it? The tag <html> I must keep it as it is or leave it alone <html>?

1 answer

6


You must change it, the tag <!DOCTYPE html> indicates to the browser that the HTML document should be read as a HTML5, just as it is documented in W3C.

@Maniero answered a question about "HTML DOCTYPE declaration", I believe it can help to have more information.

As to the xmls on your tag html, has a question and answer on this too: When to use the xmlns attribute in the html element?

According to the answer (a brief summary) the use of xmlns="http://www.w3.org/1999/xhtml" indicates that the syntax used in the document is actually XHTML5 and not HTML5.

For questions on how to maintain compatibility with previous versions, I recommend this question: How to change an HTML 4 document to HTML 5?

Also according to the answer, the tag <!DOCTYPE html> "makes code compatible with HTML 5 and earlier versions".

I also recommend seeing: It is correct to omit the html start tag in HTML5?

  • Only the man. Obg!

  • And the parade of <html>?

  • @dvd I added the answer :)

  • @dvd I believe that if what you want is to use HTML5 instead of XHTML5, you should remove it.

  • I must leave only <html>?

  • @dvd I found something about, here at Sopt also: https://answall.com/questions/58613/como-alterar-um-document-html-4-para-html-5?rq=1

  • No po. I just don’t know much about doctype.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.