CodeStride
Your First Web Page

What HTML is in HTML & CSS

Topic 1 of 58 · 7 minFree lesson

Every web page you have ever visited is built with HTML. HTML is the language that tells a browser what is on a page: headings, paragraphs, pictures and links. A browser is the app you use to visit websites, like Chrome, Safari or Firefox. It reads the HTML and draws the page you see.

In this course you write HTML and see the page it makes right away, in a preview next to your code.

Tags and elements

You describe each part of a page with tags. A tag is a word between angle brackets, like <p>. Most tags come in pairs: an opening tag <p> and a closing tag </p>. The closing tag has a slash before the word.

Example 1
<p>Hello, world!</p>
Result

The opening tag, the text inside and the closing tag together make an element. This one is a paragraph element, because p stands for paragraph.

A first page

A page is a list of elements, one after another. The <h1> tag marks the main heading of a page.

Example 2
<h1>My first web page</h1><p>I am learning HTML.</p><p>This is my second paragraph.</p>
Result

You didn't ask for big, bold text, but the heading has it. Browsers give every element a built-in look. Headings are large, and each paragraph starts on a new line with a gap above it. Later in the course you'll change these looks with CSS.

Spaces and new lines

The browser treats any run of spaces and new lines inside your text as a single space.

Example 3
<p>Lots of spaces and a new line.</p>
Result

The text comes out on one line with single spaces. HTML describes what each piece of text is, not where it sits. To start a new paragraph, you use a new <p> element.

Common mistakeA closing tag needs its slash: </h1>, not <h1>. Without the slash, the browser thinks a new heading has started. Everything after it turns into heading text.
Example 4Don't do this
<h1> Welcome <h1> <p>This text should be small.</p> </h1></h1>
Result
TipWrite your tags in lowercase, like <p> and <h1>. Browsers accept capitals too, but lowercase is the usual style and easier to read.

Try it yourself

Run the code in the editor and answer 8 practice questions on what html is. It's free, you only need an account.