Spread the love

Hello, and welcome to this short article on the <!DOCTYPE html> declaration in HTML5.

The <!DOCTYPE html> declaration is an important part of your HTML document that tells a web browser which version of HTML you are using. It is the first line of code and should be one of the very first things written into your HTML document.

If you are writing in HTML5, the <!DOCTYPE html> declaration should look like this:

<!DOCTYPE html>

It is important to note that the <!DOCTYPE html> declaration is not case sensitive; so `<!doctype html>`, `<!Doctype html>`, and `<!DOCTYPE HTML>` are all valid.

However, if you do not use the correct <!DOCTYPE html> declaration then your web browser may interpret the HTML page incorrectly, leading to unexpected results.

Now let’s take a look at an example of how the `<!DOCTYPE html>` declaration is used in a simple HTML5 document:

            
                <!DOCTYPE html>
                <html>
                <head>
                    <title>My Document</title>
                </head>
                <body>
                    <h1>Welcome to My Website!</h1>
                    <p>This is a sample HTML document.</p>
                </body>
                </html>
            
        

As you can see, the `<!DOCTYPE html>` declaration is at the very top of the document, before the `` tag. This tells the web browser that the document is written in HTML5, ensuring correct interpretation and rendering of the page.

That’s it for this video on the <!DOCTYPE> declaration in HTML5. Don’t forget to subscribe to my YouTube channel, as I will be adding more web development videos.

Happy coding!