layout: post hide: True title: Basics of HTML Guide description: An introduction to basic HTML, and resources to learn more. type: ccc permalink: /basics/html author: Rohan Juneja —

Home HTML Data Types DOM JavaScript JS Debugging

How does HTML work?

Similar function to Markdown, syntax defines how stuff should be displayed

  • HTML is based on beginning and closing tags <tagname>content</tagname>
    • Note the “/” on the ending or closing tag of the pair

Compare markdown to html below

This below example shows comparison of a heading and paragraph. Click on links to see many more HTML examples.

%%markdown

### Markdown: This is a Heading

This is a paragraph

Markdown: This is a Heading

This is a paragraph

%%html

<h3>HTML: This is a Heading</h3>
<p>This is a paragraph.</p>

HTML: This is a Heading

This is a paragraph.

Attributes

  • Learn about attributes
  • Tags can have additional info in the form of attributes
  • Attributes usually come in name/value pairs like: name=”value”
<tagname attribute_name="attribute_value" another_attribute="another_value">inner html text</tagname>
  • href example with attribute for web link and inner html to describe link
<a href="https://www.w3schools.com/html/default.asp">Visit W3Schools HTML Page</a>

Sample Markdown vs HTML Tags

Image Tag - Markdown

![describe image](link to image)

Image Tag - HTML

<!-- no content so no end tag, width/height is optional (in pixels) -->
<img alt="describe image" src="link to image" width="100" height="200">

Link Tag - Markdown

[link text](link)

Link Tag - HTML

<a href="link">link text</a>

Bolded Text - Markdown

**Bolded Text**

Bolded Text - HTML

<strong>Bolded Text</strong>

Italic Text - Markdown

*Italic Text*

Italic Text - HTML

<i>Italic Text</i>

More tags (not really in markdown)

P tag (just represeants a paragraph/normal text)

<p>This is a paragraph</p>

Button

<button>some button text</button>

Div (groups together related content)

<!-- first information -->
<div>
    <!-- notice how tags can be put INSIDE eachother -->
    <p>This is the first paragarph of section 1</p>
    <p>This is the second paragraph of section 1</p>
</div>

<!-- second information -->
<div>
    <!-- notice how tags can be put INSIDE eachother -->
    <p>This is the first paragarph of section 2</p>
    <p>This is the second paragraph of section 2</p>
</div>

Resources

  • https://www.w3schools.com/html/default.asp
  • I will show a demo of how to find information on this website

HTML Hacks

  • Below is a wireframe for an HTML element you will create. A wireframe is a rough visual representation of HTML elements on a page and isn’t necessarily to scale or have the exact styling that the final HTML will have. Using the syntax above, try to create an HTML snippet that corresponds to the below wireframe.
  • The “a tags” can contain any links that you want

wireframe for html hacks

%%html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Stacked Boxes with Links</title>
    <style>
        /* CSS for the container */
        .container {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        /* CSS for the main boxes */
        .box {
            width: 300px;
            height: 150px;
            border: 1px solid #000;
            margin: 10px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 10px;
            background-color: #3a3a3a; /* Background color for the main boxes */
        }

        /* CSS for the smaller boxes inside */
        .small-box {
            flex-grow: 1;
            border: 1px solid #f3f3f3;
            margin: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #3a3a3a; /* Background color for the smaller boxes */
        }

        /* Specific positioning for the top box */
        .top-box {
            width: 300px;
            height: 75px; /* Adjusted height of the top box */
        }

        /* Specific positioning for the bottom box */
        .bottom-box {
            width: 300px;
            height: 75px; /* Adjusted height of the bottom box */
        }

        /* Smaller box within the top box (Link 1) */
        .top-small-box:nth-child(1) {
            flex-grow: 1;
            width: 33.33%; /* Adjusted width for Link 1 (1/3rd) */
            height: 30px; /* Adjusted height of the top small box */
        }

        /* Smaller box within the bottom box (Link 4) */
        .bottom-small-box:nth-child(1) {
            flex-grow: 1;
            width: 100%;
            height: 40px; /* Adjusted height of the bottom small box */
        }

        /* Smaller box within the top box (Link 2) */
        .top-small-box:nth-child(2) {
            flex-grow: 1;
            width: 33.33%; /* Adjusted width for Link 2 (1/3rd) */
            height: 30px; /* Adjusted height of the top small box */
        }

        /* Smaller box within the bottom box (Link 5) */
        .bottom-small-box:nth-child(2) {
            flex-grow: 1;
            width: 33.33%; /* Adjusted width for Link 5 (1/3rd) */
            height: 40px; /* Adjusted height of the bottom small box */
        }

        /* Smaller box within the top box (Link 3, reverted to previous width) */
        .top-small-box:nth-child(3) {
            flex-grow: 1;
            width: 100%; /* Reverted width for Link 3 */
            height: 30px; /* Adjusted height of the top small box */
        }

        /* Links within the smaller boxes */
        .small-box a {
            text-decoration: none;
            color: #a693ff;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- Bottom Box (Flipped to the top) -->
        <div class="box bottom-box">
            <div class="small-box bottom-small-box">
                <a href="#">P </a>
            </div>
            <div class="small-box bottom-small-box">
                <a href="#">Button 1 </a>
            </div>
        </div>
        <!-- Top Box (Flipped to the bottom) -->
        <div class="box top-box">
            <div class="small-box top-small-box">
                <a href="#">A</a>
            </div>
            <div class="small-box top-small-box">
                <a href="#">A</</a>
            </div>
            <div class="small-box top-small-box">
                <a href="#">P</a>
            </div>
        </div>
    </div>
</body>
</html>


<!-- put your HTML code in this cell, Make sure to press the Run button to see your results below -->

<!DOCTYPE html>

Stacked Boxes with Links