This article is currently in the process of being translated into French (~18% done).
If you are fluent in French, then please help us - just point to any untranslated element (highlighted with a yellow left border - remember that images should have their titles translated as well!) inside the article and click the translation button to get started. Or have a look at the current translation status for the French language.
If you see a translation that you think looks wrong, then please consult the original article to make sure and then use the vote button to let us know about it.
Please help us by translating the following metadata for the article/chapter, if they are not already translated.
If you are not satisfied with the translation of a specific metadata item, you may vote it down - when it reaches a certain negative threshold, it will be removed. Please only submit an altered translation of a metadata item if you have good reasons to do so!
Your First Webpage
Voici un exemple de l'un des documents HTML5 les plus simples que vous pouvez créer. Il commence par le doctype HTML5, suivi d'un titre de page, puis d'un contenu, dans ce cas un seul paragraphe.
<!DOCTYPE html> <title>Your first HTML5 Document</title> <p>Okay, now we’re going somewhere!</p>
Vous devriez avoir une idée de ce à quoi cela ressemblerait dans un navigateur - Le titre du document, "Your first HTML5 Document" et le texte "Okay, now we're going somewhere !" écrit en haut à gauche de la page.
La déclaration doctype indique à tous ceux qui lisent le document que ce qui suit est du contenu HTML.
If you have looked at the markup of HTML documents before, you might have seen a doctype declaration that looked a lot like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Even professional webdevelopers copy and pasted this long doctype from one document to another – the new simpler doctype is easy to remember and as no specific version is declared, all new future features are automatically available to your page.
What is the DOCTYPE for?
But why is there a doctype at all? All browsers have two different ways of reading your document – standard mode and quirks mode. If you don’t tell them what kind of document they are handling, the will go into quirks mode. Think of this as the old way of reading your document – there might be some flaws and you can be sure that not all browsers read your document the same way. Declaring a doctype forces the browsers to go into standard mode – the "new" way of reading your document. Using standard mode, most browsers will read your document the same way and they will actually understand what you are writing.
To make the HTML5 document easier for yourself to understand, you would want to use the two section-elements <head> and <body>. Using these sections you clearly separate the information about your page (the head) from the actual content (body). Using these, you webpage would look like this:
<!DOCTYPE html> <head> <title>Your first HTML5 Document</title> </head> <body> <p>Okay, now we’re going somewhere!</p> </body>
What just happened with the indenting, you might think? Whether or not you want to use indenting is your own choice but it visualizes the structure of your page and makes it easier to see at a glance.
The last thing you would want to add is the <html> element and it is placed right after the doctype-declaration.
<!DOCTYPE html> <html> <head> <title>Your first HTML5 Document</title> </head> <body> <p>Okay, now we’re going somewhere!</p> </body> </html>
Congratulations you’ve just created your first HTML5 webpage! Did you notice how the <p> element is inside the <body> element? That is called nesting elements and it is a very essential part of the HTML structure. I will leave it at this for now, but I just wanted to introduce to you the idea of nesting elements.
What you have learned
- Always declare the doctye - <!DOCTYPE html>
- Use the element <head> to separate the information about your page
- Use the element <body> to separate the actual content of your webpage
- Using <html>, <head>, and <body> is a matter of style when you use HTML5, but it makes the structure of the page clearer to you.
- Indenting your markup makes it easier to comprehend
- You can nest one element inside another element