← HTML practicum

Lesson 01 · 12 steps

Tags, attributes, text

The first page of a site about Counter-Strike 2. Everything here lives in one file, main.html: how a document is built, attributes, headings, font styling and the characters HTML keeps for itself.

Hand in main.html
What the browser makes of it open on its own ↗
02The site's name on screenThe task: print the name of your site in the browser.code ↓
<html>
<head><meta charset="utf-8">
  <title> CS2 UA. Головна сторінка </title>
</head>

<!-- 2) назва сайту -->
<p> CS2 UA — сайт про Counter-Strike 2 </p>

A document has two halves. head holds what nobody sees on the page: the encoding, and title — the label on the browser tab. body holds what a person actually reads.

The utf-8 line is not a formality here. Without it the browser has no idea the text is Ukrainian and shows a row of question marks instead of letters.

Today

A document starts with <!doctype html>, and the html tag gets a language: <html lang="uk">. Skip the doctype and the browser falls back to a compatibility mode built for 1990s pages, where some sizes are measured differently.

03AttributesThe task: show tag attributes in use; the code should explain what the site is about.code ↓
<!-- 3) атрибути тега: align -->
<p align="center"> Цей сайт про Counter-Strike 2 — командний шутер, у якому п'ятеро грають проти п'ятьох </p>
<p align="center"> Тут зібрано все: мапи, зброя, економіка раунду та українські команди </p>

An attribute is a setting written inside the opening tag. Here align="center" centres the paragraph on the page.

Today

align was dropped from HTML: centring is appearance, and appearance belongs in CSS (text-align:center). The assignment asks for it because the lesson is about attributes, not about layout.

04Text on the same line as bodyThe task: text written on the same line as the body tag.code ↓
<!-- 4) текст на одному рядку з тегом body -->
<body> Counter-Strike 2 вийшла 27 вересня 2023 року і замінила CS:GO на рушії Source 2.

Where a line ends in the source makes no difference to the browser: text tucked straight after <body> and text on the next line come out the same. A line break in the code is not a line break on the page.

05Nested tagsThe task: nested tags producing formatted text on the site's subject.code ↓
<!-- 5) вкладені теги, форматований текст -->
<p> У матчі дві сторони: <b>терористи</b> закладають бомбу, а <i>контртерористи</i> їм заважають. </p>

Tags nest like boxes: b and i sit inside the paragraph. One rule only — close them in reverse order, last opened first closed.

06Forcing a line breakThe task: a new paragraph with a forced line break using br.code ↓
<!-- 6) примусовий перехід на новий рядок тегом br -->
<p> Раунд триває 1 хвилину 55 секунд. <br/> Закладена бомба вибухає через 40 секунд. </p>
<br/>
<p> Розмінувати бомбу можна за 10 секунд, <br/> а з кусачками — удвічі швидше, за 5 секунд. </p>

<p> is a paragraph, and browsers leave a gap between paragraphs. <br> is a break inside one paragraph, with no gap. The preview above shows both.

Today

Empty <br> tags are no longer used to push blocks apart — that is what margin is for. The break survives for places where the line really is one thing: an address, a verse, a match score.

07Headings h1 to h6The task: print headings with h1 and h6 for two new paragraphs.code ↓
<!-- 7) заголовки h1 і h6 -->
<h1> Карти, на яких грають турніри </h1>
<p> Dust II, Mirage, Inferno, Nuke, Overpass, Ancient та Anubis — активний пул карт змінюється щороку. </p>
<h6> Найстаріша карта пулу — Dust II, вона з'явилася ще в першій Counter-Strike </h6>

Six levels of heading are not six font sizes — they are the structure of the text. h1 names the page, h2 a section, and so on down. Browsers happen to draw them in shrinking sizes because that reads well.

Today

Search engines and screen readers navigate a page by its headings, which is why a heading is chosen by meaning and never by which size looks nicer.

08Several attributes on one tagThe task: show the syntax for several attributes on one tag; two paragraphs about what makes your site different.code ↓
<!-- 8) кілька атрибутів в одному тегові -->
<p align="right" title="Олександр Костилєв — український кіберспортсмен"> Найвідоміший український гравець — s1mple, снайпер київської команди Natus Vincere. </p>
<p align="left" title="Major — головний турнір року в Counter-Strike"> Natus Vincere виграла Major у Стокгольмі 2021 року — перший Major для української організації. </p>

Attributes are simply listed, separated by spaces. title never appears on the page — it surfaces as a tooltip if you rest the mouse on the text for a second. Try it in the preview above.

09Font stylingThe task: four different kinds of font styling, using nested tags.code ↓
<!-- 9) накреслення шрифту -->
<p> Щоб підняти розмір на пункт, є <big>тег big</big>, а щоб опустити — <small>тег small</small>. </p>
<p> <b>AK-47</b> і <strong>AWP</strong> — головна зброя терористів, а <i>M4A4</i> та <em>M4A1-S</em> стоять на боці контртерористів. </p>
<p> Назви команд у таблиці турніру зручно писати <tt>моноширинним шрифтом</tt>, щоб колонки не з'їжджали. </p>

b and strong look identical and mean different things: b is just bold, strong is important. Same with i and em — slanted versus stressed. Browsers show the difference to the eye; strong and em also carry it to a screen reader, which changes its voice.

Today

big and tt are gone from the language, and small survives with a new job — the fine print. Size is set with font-size and monospaced text is marked with code.

10Special charactersThe task: two paragraphs using the characters HTML reserves for itself; a formula is allowed.code ↓
<!-- 10) спеціальні символи -->
<p> Counter-Strike 2 &copy; 2023 Valve Corporation </p>
<p> Точність стрільби падає в русі приблизно на 70 &#37;, тому стріляють зі стійки </p>
<p> Розкид кулі: &plusmn; 2 градуси &#35;1 постріл &amp; &sect; правила економіки </p>
<p> Якщо гроші &gt; 4750 — можна купити AWP, <br/> якщо гроші &lt; 2700 — на AK-47 уже не вистачить </p>
<p> Формула переваги в раунді проста: гравці<sup>2</sup> + економіка<sup>2</sup> </p>

Characters that mean something to HTML are written as a substitution: &lt; for «less than», &gt; for «greater than», &amp; for the ampersand itself. Write them literally and the browser decides a tag has started. The rest go in by name (&copy;) or by number (&#37; — the per cent sign).

The sample in the assignment leaves the semicolon off — &copy. Browsers sometimes guess correctly, but the rule is that every substitution ends in a semicolon; without it, whatever follows can be swallowed.

11Marking words with spanThe task: two paragraphs where span singles out words or letters.code ↓
<!-- 11) виділення слів тегом span -->
<p align="left"> <span style="color:red">C4</span> — бомба, яку терористи закладають на точці A або B. </p>
<p align="left"> На <span style="color:blue">pistol round</span> обидві команди мають лише пістолети і 800 доларів. </p>

span does nothing on its own — it is an empty container around part of a line, there to be given a colour or a font later. Its sibling div is the same idea for a whole block.

Today

Colour written into the tag (style="color:red") is the quickest way and the worst one for a site of any size: changing the shade means editing every single line. Lesson 2 moves it out into a file of its own.