A Complete Guide - Web Designing Creating Web Pages with HTML

Last Updated: 03 Jul, 2025   
  YOU NEED ANY HELP? THEN SELECT ANY TEXT.

Explaining Web Designing: Creating Web Pages with HTML

HTML Document Structure: A basic HTML document consists of elements enclosed within a <!DOCTYPE html> declaration, which tells the browser about the version of HTML being used. Here is a simple example:

<!DOCTYPE html>
<html>
<head>
    <title>My First Web Page</title>
</head>
<body>
    <h1>Welcome to My First Web Page</h1>
    <p>This is a paragraph.</p>
</body>
</html>
  • <!DOCTYPE html>: Declares the document type and version of HTML.
  • <html>: The root element of an HTML page.
  • <head>: Contains meta-information like the document's title and links to scripts and stylesheets.
  • <title>: Sets the title of the web page, displayed in the browser's title bar or tab.
  • <body>: Contains the content of the HTML document visible to visitors, including headings, paragraphs, images, links, etc.

Key HTML Elements:

  1. Headings (<h1> to <h6>):

    • Used to define headings of different levels.
    • <h1> is the highest (biggest), <h6> is the smallest (smallest).
  2. Paragraphs (<p>):

    • Used to create blocks of text.
  3. Links (<a>):

    • Represents a hyperlink, linking to other web pages or resources.
    • Example: <a href=" Example</a>
  4. Images (<img>):

    • Used to insert images.
    • Requires src attribute for the image file path and alt for the alternative text.
    • Example: <img src="example.jpg" alt="Example Image">
  5. Lists:

    • Ordered Lists (<ol>): Renders a numbered list.
    • Unordered Lists (<ul>): Creates a bulleted list.
    • List Items (<li>): Used within <ol> or <ul> to define individual list items.
  6. Divisions (<div>):

    • Serves as a container for other HTML elements.
    • Helps in organizing and styling HTML documents.
  7. Spans (<span>):

    • Used to define a section within a text and is often used for styling a specific part of the text.
  8. Semantic Elements:

    • Introduced in HTML5, these elements convey the meaning of the content, improving accessibility and SEO.
    • Examples: <header>, <footer>, <article>, <section>, <main>, etc.
  9. Tables (<table>):

    • Used to organize data in rows and columns.
    • Elements like <tr>, <th>, and <td> define table structure and content.
  10. Forms (<form>):

    • Allows users to input data, typically submits it to a server.
    • Elements like <input>, <textarea>, <select>, and <button> create interactive forms.

HTML Attributes: HTML attributes provide additional information about HTML elements. They are specified within the opening tag and come in name/value pairs.

  • Syntax: attribute="value"

Common attributes include:

  • class and id: Used to style elements using CSS.
  • src: Specifies the source URL for elements like images and scripts.
  • href: Defines the destination URL for links.
  • width and height: Sets dimensions for images and tables.
  • alt: Provides alternative text for images.

HTML Comments: Comments are used to add notes to your HTML code. They are not displayed in the browser.

  • Syntax: <!-- This is a comment -->

Best Practices:

  • Use semantic HTML whenever possible.
  • Keep your code clean and organized.
  • Always validate your HTML to ensure it meets standards.
  • Optimize images for faster load times.
  • Use comments to document complex sections of your code.

Advanced Concepts:

  • CSS (Cascading Style Sheets): Styles and lays out web pages.
  • JavaScript: Adds interactivity to web pages.
  • Responsive Design: Ensures web pages look good on all devices.

Tools and Resources:

  • Text Editors: Code editors like Visual Studio Code, Sublime Text, or Atom.
  • Browsers: Popular browsers include Chrome, Firefox, Safari, and Edge.
  • Online Tutorials: Platforms like Codecademy, W3Schools, and freeCodeCamp offer comprehensive HTML tutorials.
  • Validator Tools: Use online HTML validators to check your code for errors.

Online Code run

🔔 Note: Select your programming language to check or run code at

💻 Run Code Compiler

Step-by-Step Guide: How to Implement Web Designing Creating Web Pages with HTML


Creating Web Pages with HTML: Complete Examples

Goal: By the end of this tutorial, you will have created a simple yet functional HTML web page. We'll start with basic structure and gradually add more features as you become comfortable with the basics.

Prerequisites:

  • Basic computer skills.
  • Text editor (such as Notepad, Visual Studio Code, Sublime Text, etc.).
  • Understanding of how to save and manage files.

Step 1: Basic Structure of an HTML Document

Every HTML document has a certain basic structure. Below is a simple example showing the basic elements:

<!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 paragraph in my first web page.</p>

</body>
</html>

Explanation:

  • <!DOCTYPE html>: Declares the document type and version of HTML.
  • <html>: The root element of the HTML document.
  • <head>: Contains meta-information about the document, like the character set, viewport settings, and the title.
  • <meta charset="UTF-8">: Specifies the character encoding for your web page.
  • <meta name="viewport" content="width=device-width, initial-scale=1.0">: Ensures that the page renders well on different devices and screen sizes.
  • <title>: Sets the title of the web page that appears in the browser tab.
  • <body>: Contains all the content visible to the user on the web page.
  • <h1>: A level 1 heading tag.
  • <p>: A paragraph tag.

Step 2: Adding More Content

Let’s add some more HTML elements such as headings (<h2>, <h3>...), links, images, and lists:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Web Page</title>
</head>
<body>

    <h1>About Me</h1>
    <p>Hello! I am Jane Doe, a web developer.</p>

    <h2>Education</h2>
    <p>I hold a degree from XYZ University in Computer Science.</p>

    <h3>Languages Known</h3>
    <ul>
        <li>English</li>
        <li>Hindi</li>
        <li>French</li>
    </ul>

    <h3>Skills</h3>
    <ol>
        <li>HTML</li>
        <li>CSS</li>
        <li>JavaScript</li>
    </ol>

    <h2>My Portfolio</h2>
    <a href=" target="_blank">Visit My Portfolio</a>
    <img src="profile-picture.jpg" alt="Profile Picture">

</body>
</html>

Explanation:

  • <ul>: Unordered List. This creates a bulleted list.
  • <li>: List Item. Used to specify items within a list.
  • <ol>: Ordered List. This creates a numbered list.
  • <a href="..." target="_blank">...</a>: Anchor Tag. Used to create hyperlinks. href specifies the link’s destination. The target="_blank" attribute allows opening the link in a new tab.
  • <img src="..." alt="...">: Image Tag. Used to embed images into the web page. src specifies the image file path, and alt provides alternate text if the image can't load.

Step 3: Adding Tables

Tables are useful for organizing data:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Web Page</title>
</head>
<body>

    <h1>About Me</h1>
    <p>Hello! I am Jane Doe, a web developer.</p>

    <h2>Education</h2>
    <p>I hold a degree from XYZ University in Computer Science.</p>

    <h3>Languages Known</h3>
    <ul>
        <li>English</li>
        <li>Hindi</li>
        <li>French</li>
    </ul>

    <h3>Skills</h3>
    <ol>
        <li>HTML</li>
        <li>CSS</li>
        <li>JavaScript</li>
    </ol>

    <h2>Project Experience</h2>
    <table border="1">
        <tr>
            <th>Project Name</th>
            <th>Description</th>
        </tr>
        <tr>
            <td>E-commerce Website</td>
            <td>A responsive online store using HTML, CSS, and JavaScript.</td>
        </tr>
        <tr>
            <td>Blog</td>
            <td>A personal blog where I post interesting programming articles.</td>
        </tr>
    </table>

    <h2>My Portfolio</h2>
    <a href=" target="_blank">Visit My Portfolio</a>
    <img src="profile-picture.jpg" alt="Profile Picture">

</body>
</html>

Explanation:

  • <table>: Creates an HTML table.
  • <tr>: Table Row. Used to specify rows inside a table.
  • <th>: Table Header. Used for header cells.
  • <td>: Table Data. Used for regular cells.

Step 4: Dividing Content into Sections with <div>

The <div> element is used for grouping block-level elements to format them with CSS or manipulate them with JavaScript:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Web Page</title>
</head>
<body>

    <div id="header">
        <h1>About Me</h1>
        <p>Hello! I am Jane Doe, a web developer.</p>
    </div>

    <div id="main-content">
        <div class="section">
            <h2>Education</h2>
            <p>I hold a degree from XYZ University in Computer Science.</p>
        </div>
        <div class="section">
            <h3>Languages Known</h3>
            <ul>
                <li>English</li>
                <li>Hindi</li>
                <li>French</li>
            </ul>
        </div>
        <div class="section">
            <h3>Skills</h3>
            <ol>
                <li>HTML</li>
                <li>CSS</li>
                <li>JavaScript</li>
            </ol>
        </div>

        <div class="section">
            <h2>Project Experience</h2>
            <table border="1">
                <tr>
                    <th>Project Name</th>
                    <th>Description</th>
                </tr>
                <tr>
                    <td>E-commerce Website</td>
                    <td>A responsive online store using HTML, CSS, and JavaScript.</td>
                </tr>
                <tr>
                    <td>Blog</td>
                    <td>A personal blog where I post interesting programming articles.</td>
                </tr>
            </table>
        </div>

        <div class="section">
            <h2>My Portfolio</h2>
            <a href=" target="_blank">Visit My Portfolio</a>
            <img src="profile-picture.jpg" alt="Profile Picture">
        </div>
    </div>

    <div id="footer">
        <p>Contact me via email: jane@example.com</p>
    </div>

</body>
</html>

Explanation:

  • <div>: Division Tag. Used to divide the webpage into sections.
  • id="..." and class="...": Attributes to give unique identity and general classification to <div> elements respectively, which can be used later with CSS and JavaScript for styling and manipulation.

Step 5: Styling the Web Page with CSS

While HTML is responsible for the content, CSS (Cascading Style Sheets) controls the presentation and layout of the content. Let's add some basic styles to our previous HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Web Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }
        #header {
            text-align: center;
            background-color: #6c757d;
            color: white;
            padding: 10px 0;
        }
        .section {
            margin-bottom: 20px;
        }
        #footer {
            background-color: #2c3e50;
            color: white;
            text-align: center;
            padding: 10px 0;
            position: fixed;
            width: 100%;
            bottom: 0;
        }
        img {
            max-width: 100%;
            height: auto;
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
    </style>
</head>
<body>

    <div id="header">
        <h1>About Me</h1>
        <p>Hello! I am Jane Doe, a web developer.</p>
    </div>

    <div id="main-content">
        <div class="section">
            <h2>Education</h2>
            <p>I hold a degree from XYZ University in Computer Science.</p>
        </div>
        <div class="section">
            <h3>Languages Known</h3>
            <ul>
                <li>English</li>
                <li>Hindi</li>
                <li>French</li>
            </ul>
        </div>
        <div class="section">
            <h3>Skills</h3>
            <ol>
                <li>HTML</li>
                <li>CSS</li>
                <li>JavaScript</li>
            </ol>
        </div>

        <div class="section">
            <h2>Project Experience</h2>
            <table border="1">
                <tr>
                    <th>Project Name</th>
                    <th>Description</th>
                </tr>
                <tr>
                    <td>E-commerce Website</td>
                    <td>A responsive online store using HTML, CSS, and JavaScript.</td>
                </tr>
                <tr>
                    <td>Blog</td>
                    <td>A personal blog where I post interesting programming articles.</td>
                </tr>
            </table>
        </div>

        <div class="section">
            <h2>My Portfolio</h2>
            <a href=" target="_blank">Visit My Portfolio</a>
            <img src="profile-picture.jpg" alt="Profile Picture">
        </div>
    </div>

    <div id="footer">
        <p>Contact me via email: jane@example.com</p>
    </div>

</body>
</html>

Explanation:

  • <style>: Defines internal CSS inside the HTML document.
  • body: Applies styles globally to the entire body of the document.
  • #header: Styles the header section specifically.
  • .section: Styles all sections marked with this class.
  • #footer: Styles the footer section specifically.
  • img: Targets all image elements to ensure they are centered and resize properly.

Step 6: Adding Interactivity with JavaScript

JavaScript can add dynamic interactivity to web pages. Let's add a simple script to change a greeting when a button is clicked:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Web Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }
        #header {
            text-align: center;
            background-color: #6c757d;
            color: white;
            padding: 10px 0;
        }
        .section {
            margin-bottom: 20px;
        }
        #footer {
            background-color: #2c3e50;
            color: white;
            text-align: center;
            padding: 10px 0;
            position: fixed;
            width: 100%;
            bottom: 0;
        }
        img {
            max-width: 100%;
            height: auto;
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
        button {
            background-color: #3498db;
            color: white;
            border: none;
            padding: 10px 20px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin-top: 10px;
            cursor: pointer;
            border-radius: 5px;
        }
    </style>
    <script>
        function changeGreeting() {
            var element = document.getElementById("greeting");
            element.innerHTML = "Hello there! Nice to meet you.";
        }
    </script>
</head>
<body>

    <div id="header">
        <h1><span id="greeting">About Me</span></h1>
        <p>Hello! I am Jane Doe, a web developer.</p>
        <button onclick="changeGreeting()">Change Greeting</button>
    </div>

    <div id="main-content">
        <div class="section">
            <h2>Education</h2>
            <p>I hold a degree from XYZ University in Computer Science.</p>
        </div>
        <div class="section">
            <h3>Languages Known</h3>
            <ul>
                <li>English</li>
                <li>Hindi</li>
                <li>French</li>
            </ul>
        </div>
        <div class="section">
            <h3>Skills</h3>
            <ol>
                <li>HTML</li>
                <li>CSS</li>
                <li>JavaScript</li>
            </ol>
        </div>

        <div class="section">
            <h2>Project Experience</h2>
            <table border="1">
                <tr>
                    <th>Project Name</th>
                    <th>Description</th>
                </tr>
                <tr>
                    <td>E-commerce Website</td>
                    <td>A responsive online store using HTML, CSS, and JavaScript.</td>
                </tr>
                <tr>
                    <td>Blog</td>
                    <td>A personal blog where I post interesting programming articles.</td>
                </tr>
            </table>
        </div>

        <div class="section">
            <h2>My Portfolio</h2>
            <a href=" target="_blank">Visit My Portfolio</a>
            <img src="profile-picture.jpg" alt="Profile Picture">
        </div>
    </div>

    <div id="footer">
        <p>Contact me via email: jane@example.com</p>
    </div>

</body>
</html>

Explanation:

  • <script>: Embeds JavaScript directly into the HTML document.
  • function changeGreeting() { ... }: Defines a JavaScript function named changeGreeting.
  • document.getElementById("greeting"): Retrieves the HTML element with ID greeting.
  • element.innerHTML = "...";: Changes the inner HTML content of the retrieved element.
  • <button onclick="changeGreeting()">...</button>: Adds a clickable button that triggers the changeGreeting function when clicked.

Final Output

Your final HTML document should look something like this:

Note: Since I can't actually produce an image of the result here, use a web browser to open the saved HTML file. You should see:

  • A centered header with a greeting and a button.
  • An educational section with a paragraph.
  • A languages known section with a bulleted list.
  • A skills section with a numbered list.
  • A project experience section with a bordered table.
  • A portfolio section with a hyperlink and a centered image.
  • A fixed footer at the bottom of the page.

Additional Tips for Beginners

  • Validate Your HTML: Use tools like W3C Markup Validation Service to check if your HTML document is well-formed.
  • Comments: Include comments in your HTML code for better readability (use <!-- Comment -->).
  • External Files: For larger projects, separate your HTML from CSS and JavaScript by storing them in external files and linking them back to your HTML document.
  • Experiment: Modify the provided examples to practice and make your own designs.

 YOU NEED ANY HELP? THEN SELECT ANY TEXT.

Top 10 Interview Questions & Answers on Web Designing Creating Web Pages with HTML

1. What is HTML, and why is it essential for web design?

Answer: HTML (HyperText Markup Language) is the standard language used to create the structure of web pages. It defines elements such as headings, paragraphs, links, and images. HTML is essential because it provides the basic framework upon which all web content is built. Without HTML, browsers wouldn't be able to understand the structure or display the information properly.

2. How do you create a hyperlink in HTML?

Answer: You can create hyperlinks using the <a> (anchor) tag. The href attribute specifies the URL to which the link points. For example:

<a href=" Example</a>

This code will create a clickable text "Visit Example" that directs users to "

3. What do the tags <div>, <section>, <article>, and <header> represent in HTML?

Answer: These tags are used to define different sections within an HTML document and help in organizing the content better.

  • <div>: A generic container used to divide the page into distinct sections. Divs are typically styled with CSS.
  • <section>: Represents a self-contained section of a document that contains content related to a particular theme. It's often used alongside headings to define new sections.
  • <article>: Defines independent, self-contained content that could be distributed or reused elsewhere. Examples could be forum posts, blog entries, news articles.
  • <header>: Contains introductory content or navigation links, usually at the top of a section or the entire page.

4. Explain how HTML forms are used, including common form elements.

Answer: HTML forms are used to collect user input data. Common form elements include:

  • <form>: Sets up the form and contains other elements like labels, text fields, checkboxes, buttons, etc.
  • <input>: Used for single-line text input, checkboxes, radio buttons, file uploads, hidden fields, and more.
  • <label>: Associated with a form control. Provides additional context about what the control is for.
  • <textarea>: Allows multi-line text input.
  • <button>: Defines a clickable button. Can be used to submit forms or perform actions.
  • <select>: Creates a dropdown list from which users can select options.
  • <fieldset> and <legend>: Groups related elements within a form and provides a caption for that group.

Example form to collect name and email:

<form action="/submit-form" method="post">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required>
    
    <label for="email">Email:</label>
    <input type="email" id="email" name="email" required>
    
    <button type="submit">Submit</button>
</form>

5. How do you embed images in an HTML document?

Answer: Images are embedded in HTML using the <img> tag. The src attribute specifies the path to the image file, while alt provides alternative text in case the image cannot be displayed.

<img src="image.jpg" alt="Description of the image" width="300" height="200">

6. What is semantic HTML, and why is it important?

Answer: Semantic HTML refers to using HTML tags that accurately describe the purpose and meaning of the content they enclose, rather than just its appearance. Tags like <header>, <nav>, <main>, <section>, and <footer> are semantic because they convey the role of the contained elements clearly. This approach enhances accessibility (e.g., for screen readers), SEO (search engine optimization), and maintainability of the website.

7. How can you include external resources like CSS and JavaScript in an HTML document?

Answer:

  • CSS (Cascading Style Sheets): Link to external CSS using the <link> tag in the <head> section of your HTML document.
<link rel="stylesheet" type="text/css" href="styles.css">
  • JavaScript: Include external JavaScript using the <script> tag. It’s generally placed before the closing </body> tag to ensure the HTML is parsed before scripts run.
<script src="script.js"></script>

8. How would you add comments in HTML?

Answer: Comments in HTML are added using the <!-- comment goes here --> syntax. They won’t be visible on the web page but are useful for adding notes or explanations in your code.

<!-- This is a comment -->
<p>This is a paragraph that will be seen by web browsers.</p>
<!-- Another comment block -->

9. Why is it necessary to use alt attributes for images?

Answer: Alt attributes are crucial for images because they provide alternative textual descriptions for images when they cannot be displayed due to various reasons (e.g., slow internet connections, broken links, browser settings, or screen readers). This not only enhances accessibility but also helps in improving SEO as search engines crawl alt attributes to understand the visual content of a page.

10. Describe the process of creating a responsive web page with HTML and CSS.

Answer: Creating a responsive web page involves building a layout that adjusts seamlessly to different devices and screen sizes. Here's a simplified process:

  1. Use HTML5 Semantic Tags: These help in creating a logical structure that can easily adapt to responsive designs.
  2. Mobile First Design Approach: Start designing for small screens and gradually add styles for larger screens.
  3. Fluid Grid Layouts: Use percentages or relative units (em, rem) instead of fixed pixel values for widths and heights.
  4. Flexible Images and Media: Set media elements to scale down appropriately via CSS.
img {
    max-width: 100%;
    height: auto;
}
  1. Media Queries in CSS: Apply different CSS rules for various screen sizes using media queries.
@media (max-width: 600px) {
    body {
        font-size: 14px;
    }
}
  1. Viewport Meta Tag: Include this tag in the HTML to control layout on mobile browsers.
<meta name="viewport" content="width=device-width, initial-scale=1.0">

Following these practices helps in creating responsive websites that offer a great user experience across devices.


You May Like This Related .NET Topic

Login to post a comment.