CSS Portal

Tinkering - HTML Tutorial

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Let’s make a few changes to our “Simple Webpage” from “Diving In”.

Example 1.3. Simple Webpage
<html>
  <head>
    <title>A Simple Webpage</title>
  </head>

  <body>
    This is a simple webpage.
    And I mean really simple.
  </body>
</html>

To see this change:

  1. Add the new text (And I mean really simple.) to your simple.html file.
  2. Save the file as adding.html.
  3. Open adding.html in your browser.

HTML and Whitespace

Notice that both sentences appear on the same line? That’s because HTML ignores extra spaces, tabs, and line breaks in your code. All consecutive whitespace is treated as a single space.

This behavior may feel odd at first, but it allows you to format your code for readability without affecting how it looks in the browser. The browser also adjusts line breaks automatically depending on window size and font.

Example 1.4, “Scattered Text” displays the same way as Example 1.3, even if the text in your code is spread across multiple lines. Try it out!

Example 1.4. Scattered Text
<html>
  <head>
    <title>A Simple Webpage</title>
  </head>

  <body>
  This is a simple webpage. And I mean really simple.
  </body>
</html>

Note

To keep examples concise, we’ll omit the html, head, title, and body elements in future examples, focusing only on the content inside the body. We’ll include the full structure again when necessary.

HTML provides ways to control whitespace more explicitly. For example, see “Paragraphs” for simple examples.

Emphasizing Text

Let’s emphasize part of the text. Change your page to:

Example 1.5. Emphasized Text
This is a simple webpage.
And I mean <em>really</em> simple.

Save and view your page. You’ll see that text inside the <em> element appears italicized. The em element marks text as emphasized - like stressing it when speaking. This is our first example of an element that affects text appearance.

For more text formatting elements, see “Font Styles”.

Changing the Background Color

Now let’s change the background color:

Example 1.6. Background Color
<html>
  <head>
    <title>A Simple Webpage</title>
  </head>

  <body style="background: yellow">
    This is a simple webpage. And I mean <em>really</em> simple.
  </body>
</html>

Try changing the background color to red, blue, teal, or papayawhip to see what works. This demonstrates an attribute - a piece of information that modifies an element’s behavior. Some elements require attributes, while others make them optional. We’ll cover attributes in detail in “Attributes”.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!