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

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Shoe Product Page</title>
    <link rel="stylesheet" href="styles.css"> <!-- You can link to an external CSS file for styling -->
</head>
<body>
    <header>
        <h1>Shoe Shop</h1>
        <nav>
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">Products</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <section class="product">
            <img src="shoe.jpg" alt="Shoe Image">
            <h2>Men's Running Shoe</h2>
            <p>High-quality running shoe designed for comfort and performance.</p>
            <p><strong>Price:</strong> $79.99</p>
            <button>Add to Cart</button>
        </section>
    </main>

    <footer>
        <p>&copy; 2023 Shoe Shop</p>
    </footer>
</body>
</html>

Shoe Product Page

Shoe Shop

Shoe Image

Men's Running Shoe

High-quality running shoe designed for comfort and performance.

Price: $79.99

© 2023 Shoe Shop

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

<html>
<head>
</head>
<body>
    <div>
        <p>LeBron James is a legendary basketball player known for his incredible skills on the court. He has won numerous championships and awards throughout his career!</p>
        <button id="dunkButton">"Dunk"!</button>
    </div>
    <div>
        <a href="https://docs.google.com/document/d/160j5RblFoiSHhxt9o7BoCjeJxp2bmlFhHIhuBIXGMgM/edit">LeBron James Dunk</a>
        <a href="https://docs.google.com/document/d/1qSDVEV-sg9p-vrqG6FtVjlf8HdwCwc7TJXfN6eNRJUk/edit">LeBron James Image</a>
        <p>Overall, LeBron James is an iconic basketball player and a true legend in the world of sports!</p>
    </div>

    <script>
        document.getElementById("dunkButton").addEventListener("click", function() {
            alert("You've been dunked on by LeBron James!");
        });
    </script>
</body>
</html>

LeBron James is a legendary basketball player known for his incredible skills on the court. He has won numerous championships and awards throughout his career!

LeBron James Profile LeBron James Career

Overall, LeBron James is an iconic basketball player and a true legend in the world of sports!