A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/Beginners/html below:

Structuring our content with HTML · WebPlatform Docs

Part 4: Structuring our content with HTML Summary

Next we will dive into Hypertext Markup Language (HTML), structuring our content. This document shows an example HTML file with notes on each components that will help you learn their use.

Beginners submenu

The Beginners section covers the various aspects of web development separated in 9 parts, you can navigate through them using this list.

Structuring Essentials

If you’re running a software, there’s plain code working behind the scenes. Similarly, with all its glitter and presentational charisma, a web page also has lots of code running (or sitting idle) behind the screen.

Every web page out there on the Internet can be seen as a document. Most web documents are written in a way so that we can distinguish images, paragraphs, titles, and so on. HTML provides a syntax that allows to make those distinctions with tags that we open and close (e.g. <strong>bold text</strong>) that we refer to as "markup". Because it gives a structure to the document.

Writing structured and re-usable HTML is an art. You have to take care of being logical (like using a header tag for a header and not your website footer!). That’s why learning to structure with best HTML practices is necessary.

In this article, we’re going to analyze the anatomy of an HTML document.

An HTML document is essentially divided into two parts: the head and the body. The head holds important metadata about the webpage, while the body holds all the content, including all text, images, colors, and the entire screen real estate. And these two parts are enclosed inside the most senior, all-encompassing html tag, that tells the browser something like “Here starts the HTML markup. Get ready.”

An Example Document in a Web Browser

The Code

You can copy and paste this code in a new file (e.g. index.html) and open it directly in a web browser to test it live!

You should see only a white page with a big “Hello world” written in red like the image above.

<!DOCTYPE html>
<html lang="en">
 <head>
   <meta charset="utf-8"></meta>
   <title>Example Page</title>
   <link rel="stylesheet" href="style1.css" type="text/css"></link>
   <style> h1 {
                  color: red;
              }
   </style>
 </head>
 <body>
   <h1>Hello world</h1>
 </body>
</html>
The Components Elaborated The Working

The HTML document works with the power of its tags. The tags work in sync to achieve the intended effect and structure. The CSS rules, attached either via a separate document, embedded rules within the HTML document’s head or by inline rules (not shown), add the style to the document.

The browser downloads and reads the HTML document line-by-line from top-to-bottom and renders the needed structure that makes more sense than the code. In essence, it converts code into logical user interface, though not very graphical. For example, to have a heading of largest size, we use h1.

Hopefully, you now understand the basic of HTML: structuring with various available tags. Indeed, there are many tags to explore. Most tags have additional attributes and a way of placement. From the HTML itself, you can serve different styles to different screens (two sets of styles to two separate devices like a portrait iPad and a landscape big monitor!), arrange your content with proper structure, and much, much more.

Going Over to Styles

We’ve created an CSS rule that translates as follows: “The h1 heading should have a red color.”

By default, everything is black. Here, we’re overriding the default. CSS is, frankly, all about overriding the defaults. Of course, there are more defaults already set in your browser, like the font size, positioning, heights and widths, backgrounds, borders, margins, shadows, the list goes on. That all is fully customisable in a very simple way from writing good CSS rules.

And that takes us to our next topic: Styling our content with CSS!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4