How to Display a Web Page in HTML Code

Displaying a web page using HTML is one of the fundamental tasks in web development. HTML (HyperText Markup Language) serves as the backbone of any web page.

First, Understanding the Basics of HTML

How to Display a Web Page in HTML Code

Each element in HTMLserves a specific purpose. For example:

<html>: Defines the root of the HTML document.

<head>: Show the-information about the page.

<body>: display the main content visible on the web page.

Step-by-Step Guide to Create and Display a Web Page

To display a web page, you need a basic structure


Code Box
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First Web Page</title>
</head>
<body>
    <h1>Welcome to My Web Page</h1>
    <p>This is a simple example of a web page created using HTML.</p>
</body>
</html>

Explanation

• <!DOCTYPE html>: .
It declares the document type as HTML5.

• <html lang="en">: 
Specifies the language of the document as English.

• <meta charset="UTF-8">: 
Sets the character encoding to UTF-8 with various characters.

• <meta name="viewport" content="width=device-width, initial-scale=1.0">: 
Ensures the page is mobile-friendly.

• <title>: 
Defines the title that show on the browser tab.

• <body>:  
Visible all content, such as headings (<h1>) and paragraphs (<p>).

Saving the File


• Open a any text editor you use like Notepad, VS Code, or Sublime Text.

• Copy and paste the HTML code.

• Save the file with the .html extension, for example, index.html.


Opening the Web Page


• Find and check the saved .html file on your computer.

• Double-click it to open in your default favourite web browser.

• You should see your web page displayed successfully.





Comments