01 Aug 2024 by Ijeoma Jahsway

Category: Web Development

Frameworks: HTML

Read Time: 15 Minutes


Web Dev Fundamentals: HTML Basics

Web Dev Fundamentals: HTML Basics

HTML Basics

Welcome to the HTML Basics section of Coder Nova! Here, we'll explore the fundamental concepts of HTML, the backbone of web development. HTML (HyperText Markup Language) is the standard markup language used to create web pages. Let's dive into the basics together!

Structure of an HTML Document

The HTML Skeleton

To start, every HTML document has a standard structure known as the HTML skeleton. It's the foundation upon which we build our web pages. Here's what it looks like:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First Webpage</title>
</head>
<body>
    <h1>Welcome to Coder Nova!</h1>
    <p>This is my first webpage.</p>
</body>
</html>

Let’s break it down:

  • <!DOCTYPE html>: This line tells the browser that we are using HTML5.
  • <html lang="en">: The <html> tag is the root element of an HTML page, and the lang attribute specifies the language.
  • <head>: Contains meta-information about the HTML document, like the character encoding and the title.
  • <meta charset="UTF-8">: Sets the character encoding to UTF-8.
  • <meta name="viewport" content="width=device-width, initial-scale=1.0">: Ensures proper rendering and touch zooming on mobile devices.
  • <title>: Sets the title of the webpage, which appears in the browser tab.
  • <body>: Contains the content of the webpage, such as headings, paragraphs, links, images, and more.

Common HTML Tags and Attributes

 

HTML uses tags to define the position, and function of elements within a document. Here is a list of HTML tags along with a brief description of their functions and use cases:

Document Structure

  1. <!DOCTYPE>: Defines the document type and version of HTML.
  2. <html>: Root element of an HTML document.
  3. <head>: Contains metadata, links to scripts and stylesheets.
  4. <title>: Sets the title of the webpage (shown in the browser tab).
  5. <body>: Contains the content of the HTML document.

Metadata

  1. <meta>: Provides metadata such as character set, description, keywords.
  2. <link>: Links to external resources like stylesheets.
  3. <style>: Embeds CSS styles within an HTML document.
  4. <script>: Embeds or references JavaScript code.

Content Sectioning

  1. <header>: Defines a header for a section or page.
  2. <nav>: Defines navigation links.
  3. <main>: Specifies the main content of the document.
  4. <section>: Defines a section in a document.
  5. <article>: Specifies independent, self-contained content.
  6. <aside>: Defines content aside from the main content.
  7. <footer>: Defines a footer for a section or page.

Text Content

  1. <h1> to <h6>: Define headings from level 1 to 6.
  2. <p>: Defines a paragraph.
  3. <a>: Defines a hyperlink.
  4. <ul>: Defines an unordered list.
  5. <ol>: Defines an ordered list.
  6. <li>: Defines a list item.
  7. <dl>: Defines a description list.
  8. <dt>: Defines a term/name in a description list.
  9. <dd>: Describes a term/name in a description list.
  10. <div>: Defines a division or section.
  11. <span>: Defines a span of text.

Inline Text Semantics

  1. <b>: Defines bold text.
  2. <i>: Defines italic text.
  3. <strong>: Defines important text.
  4. <em>: Defines emphasized text.
  5. <mark>: Defines marked/highlighted text.
  6. <small>: Defines smaller text.
  7. <del>: Defines deleted text.
  8. <ins>: Defines inserted text.
  9. <sub>: Defines subscripted text.
  10. <sup>: Defines superscripted text.
  11. <br>: Inserts a line break.
  12. <hr>: Defines a thematic change or break in the content.

Media Content

  1. <img>: Embeds an image.
  2. <audio>: Embeds audio content.
  3. <video>: Embeds video content.
  4. <source>: Specifies multiple media resources.
  5. <track>: Defines text tracks for <video> and <audio> elements.
  6. <picture>: Contains multiple <source> elements for different media types.

Embedded Content

  1. <iframe>: Embeds another HTML page within the current page.
  2. <embed>: Embeds external content or application.
  3. <object>: Embeds an external resource.
  4. <param>: Defines parameters for <object>.

Form Elements

  1. <form>: Defines an HTML form for user input.
  2. <input>: Defines an input control.
  3. <textarea>: Defines a multiline text input control.
  4. <button>: Defines a clickable button.
  5. <select>: Defines a drop-down list.
  6. <option>: Defines an option in a drop-down list.
  7. <label>: Defines a label for an input element.
  8. <fieldset>: Groups related elements in a form.
  9. <legend>: Defines a caption for a <fieldset>.
  10. <datalist>: Specifies a list of pre-defined options for an <input> element.
  11. <output>: Represents the result of a calculation.

Table Content

  1. <table>: Defines a table.
  2. <caption>: Defines a table caption.
  3. <tr>: Defines a table row.
  4. <th>: Defines a header cell in a table.
  5. <td>: Defines a standard cell in a table.
  6. <thead>: Groups the header content in a table.
  7. <tbody>: Groups the body content in a table.
  8. <tfoot>: Groups the footer content in a table.
  9. <col>: Specifies column properties for each column within a <colgroup>.
  10. <colgroup>: Specifies a group of one or more columns in a table for formatting.

Scripting

  1. <script>: Embeds or references executable code.
  2. <noscript>: Defines alternate content for users who do not support client-side scripting.

Interactive Elements

  1. <details>: Specifies additional details the user can view or hide.
  2. <summary>: Defines a visible heading for the <details> element.
  3. <dialog>: Defines a dialog box or window.
  4. <menu>: Defines a list/menu of commands.

Deprecated/Obsolete Elements (Not recommended for use)

  1. <applet>: Embeds a Java applet.
  2. <basefont>: Sets default font size, color, and face.
  3. <center>: Centers text.
  4. <font>: Specifies the font face, size, and color of text.
  5. <frame>: Defines a window (a frame) in a frameset.
  6. <frameset>: Defines a set of frames.
  7. <noframes>: Provides alternative content for browsers that do not support frames.

This list covers the most common HTML tags and their functions. Each tag serves a specific purpose, allowing web developers to structure and present web content effectively. But don't be overwhelmed just yet... Like Bruce Lee said.

I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.

You only need to choose your weapons and master them efficiently. Let’s go through some of the most commonly used tags and their attributes.

Headings

Headings are used to define the titles and subtitles in your content. HTML provides six levels of headings, from <h1> to <h6>, where <h1> is the highest level.

<h1>Welcome to my website!</h1>
<h2>Welcome to my website!</h2>
<h3>Welcome to my website!</h3>
<h4>Welcome to my website!</h4>
<h5>Welcome to my website!</h5>
<h6>Welcome to my website!</h6>

Paragraphs and Text

Paragraphs are used to define blocks of text. Additionally, HTML provides tags to emphasize text.

<p>This is a paragraph.</p>
<strong>Bold text</strong>
<em>Italic text</em>
  • <p>: Defines a paragraph.
  • <strong>: Makes text bold.
  • <em>: Makes text italic.

Links and Images

Links and images are essential for creating interactive and visually appealing web pages.

<a href="https://www.example.com">Visit Example</a>
<img src="image.jpg" alt="Description of image">
  • <a>: Defines a hyperlink. The href attribute specifies the URL.
  • <img>: Embeds an image. The src attribute specifies the image source, and alt provides alternative text for the image.

Lists

Lists are used to group related items. There are two types of lists: unordered lists and ordered lists.

<ul>
    <li>Item 1</li>
    <li>Item 2</li>
</ul>
    
<ol>
    <li>First item</li>
    <li>Second item</li>
</ol>
  • <ul>: Defines an unordered (bulleted) list.
  • <ol>: Defines an ordered (numbered) list.
  • <li>: Defines a list item

Tables

Tables are used to display data in a tabular format.

<table>
    <tr>
        <th>Header 1</th>
        <th>Header 2</th>
    </tr>
    <tr>
        <td>Cell 1</td>
        <td>Cell 2</td>
    </tr>

</table>
  • <table>: Defines a table.
  • <tr>: Defines a table row.
  • <th>: Defines a table header cell.
  • <td>: Defines a table data cell.

Creating a Simple Webpage

Now that we've covered the basics, let's create a simple webpage together. Follow these steps:

Step-by-Step Guide

1. Set Up the Document Structure

Start with the HTML skeleton:

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

</body>
</html>

2. Add Content to the Body

Add a heading and a paragraph:

<body>
    <h1>Welcome to My Simple Webpage</h1>
    <p>This is a paragraph describing my webpage.</p>
</body>

3. Insert a Link and an Image

Add a hyperlink and an image:

<body>
    <h1>Welcome to My Simple Webpage</h1>
    <p>This is a paragraph describing my webpage.</p>
    <a href="https://www.example.com">Visit Example</a>
    <img src="image.jpg" alt="Example image">
</body>

4. Create a List

Add an unordered list:

<body>
    <h1>Welcome to My Simple Webpage</h1>
    <p>This is a paragraph describing my webpage.</p>
    <a href="https://www.example.com">Visit Example</a>
    <img src="image.jpg" alt="Example image">
    <ul>
        <li>First item</li>
        <li>Second item</li>
        <li>Third item</li>
    </ul>
</body>

5. Add a Table

Insert a simple table:

<body>
    <h1>Welcome to My Simple Webpage</h1>
    <p>This is a paragraph describing my webpage.</p>
    <a href="https://www.example.com">Visit Example</a>
    <img src="image.jpg" alt="Example image">
    <ul>
        <li>First item</li>
        <li>Second item</li>
        <li>Third item</li>
    </ul>
    <table>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
        </tr>
        <tr>
            <td>Cell 1</td>
            <td>Cell 2</td>
        </tr>
    </table>
</body>

Final Code

Here's the complete HTML code for our simple webpage:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Simple Webpage</title>
</head>
<body>
    <h1>Welcome to My Simple Webpage</h1>
    <p>This is a paragraph describing my webpage.</p>
    <a href="https://www.example.com">Visit Example</a>
    <img src="image.jpg" height="200" alt="Example image">
    <ul>
        <li>First item</li>
        <li>Second item</li>
        <li>Third item</li>
    </ul>
    <table>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
        </tr>
        <tr>
            <td>Cell 1</td>
            <td>Cell 2</td>
        </tr>
    </table>
</body>
</html>

Conclusion

In this section, we've covered the basics of HTML, including the structure of an HTML document, common tags and attributes, and how to create a simple webpage. With this foundation, you're ready to move on to CSS Basics, where we'll learn how to style our webpage and make it visually appealing. Stay tuned!

Feel free to experiment with different tags and attributes to see how they change your webpage!

 

Join Us on Telegram!

Subscribe to our Telegram Channel to get exclusive content and be the first to know when new blog posts go live! 🎉

Comments

No comments...

Leave a Comment

Author
Ijeoma Jahsway
Ijeoma Jahsway @admin

#Web design basics #HTML fundamentals #Front-end development basics #Learn to code HTML #HTML syntax #HTML basics tutorial #HTML elements #HTML coding basics

Delta State, Nigeria

Related Articles

See More

For you

See More