Internet Technologies

Tasks studies - laboratory


Project maintained by dawidolko Hosted on GitHub Pages — Theme by dawidolko

Basics of HTML5

Useful Resources:

link – the official specification of the HTML language; note that it is not versioned (unlike many programming languages). For example, there is no version 5.0.1 that might later be replaced by another version – only the date of the last change is recorded. This specification is the most important model for writing correct HTML documents. Historically, the W3C originally published versioned editions of HTML (the last marked as 5.3), which were all withdrawn on January 28, 2021 (all that ever existed).

link – the Mozilla Foundation website containing HTML documentation, interactive tutorials, and guides.

https://pl.wikipedia.org/wiki/HTML

https://pl.wikipedia.org/wiki/HTML5

HTML has been evolving for about 30 years. In the early period, practical implementations (i.e. browsers) often imposed certain solutions while official specifications were produced very slowly—and even when some results were achieved, they were sometimes rejected by the community. The first specification that achieved some stability was HTML4, released in 1997. HTML4 was formally a specific type of SGML (i.e. an application of SGML). Later, XHTML was developed—that is, figuratively speaking, HTML parsed as XML (also an XML application). HTML5 emerged as a result of dissatisfaction with both HTML4 and XHTML (especially regarding their complexity) and the need to unify the way web pages are created.

It is worth noting that in this guide the word “webpage” will be used interchangeably with the concept of an HTML document.

“HTML5 Document Skeleton”:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body></body>
</html>

Tags (also known as elements):

• An opening tag, the content of the tag, and a closing tag:

<tag>content of the tag</tag>

• A tag without content (empty), which does not require a closing tag:

<tag></tag>

English naming conventions (useful when reading documentation):


lab1

<!-- This is a comment in HTML -->

Tag Attributes:

<tag attr1="value1" attr2="value2">content of the tag</tag>
<tag attr1="value1" attr2="value2" attr3="value3">
  <tag attr1="value1 value2 value3" attr2="value2">content of the tag</tag></tag
>

A tag can have multiple attribute values, which are separated by a space:

<tag attr1="value1 value2 value3" attr2="value2">content of the tag</tag>

There are also attributes that do not have any value:

<tag attr1>content of the tag</tag>

In practice, it is acceptable to “shorten” binary attributes in this way, following the convention that the presence of the attribute means its default value is true, and its absence sets the attribute to false. It is also possible to specify the attribute’s name or an empty value to indicate that it has a true value. However, explicitly assigning “true” or “false” is incorrect—that is, the official Living Standard forbids this (even though it is encountered in practice and supported by browsers).

<tag attr1="">content of the tag</tag>
<!-- correct -->
<tag attr1="attr1">content of the tag</tag>
<!-- correct -->

<tag attr1="false">content of the tag</tag>
<!-- incorrect -->
<tag attr1="true">content of the tag</tag>
<!-- incorrect -->

There are two groups of attributes: local and global.

<tag id="introduction" class="">content of the tag</tag>
<img src="/images/red_panda.jpg" alt="red panda" />

Attributes can be informally compared to the properties (fields) of an object.


Hints and Tips:


The HTML Specification Distinguishes the Following Categories of Elements:


lab1

link


Task 1.

Create an index.html document (the common name for the main HTML document, automatically loaded by the HTTP server when a website URL is entered), and within it the document skeleton. The language of the document should be Polish, and the title should read:
“Jan Kowalski – muzyka to moja pasja”
(which translates to “Jan Kowalski – music is my passion”).

Open Visual Studio Code and open a project (folder) named LAB002. For clarity of the project tree, install the VSCode extension called Material Icon Theme, which provides icons for files and folders that suggest their content.


lab1

Type the string html: in the created index.html file and press Enter to insert the basic HTML5 document snippet.


lab1

Set the page title in the <title> tag to “Jan Kowalski - z pasją do muzyki” (“Jan Kowalski - with a passion for music”).

Install the extension “Live Server”. This is a development server (used for creating pages, not hosting them in production). The word “Live” means that after any change the server reloads the page and renders it immediately.


lab1

Run the page in the browser by right-clicking in the editor and selecting Open with Live Server.


lab1

The extension will automatically refresh the page after saving the file in VSCode.


lab1

An unsaved file is indicated by a dot on the file’s tab. Save the file and remember the shortcut (Ctrl+S) for saving (the dot should disappear and the page in the browser should refresh).

There is also an option to install an extension that renders HTML inside VSCode for a quick preview.


lab1

To enable the preview, first press Ctrl+Q and then, after releasing these keys, press S.


Task 2.

The tags <h1> to <h6> are used to create headings for sections of a document.

The first-level heading <h1> is the most important. In the past it was recommended to use it only once per document; however, HTML5 has removed this restriction. Headings may appear multiple times in a document.


lab1

The tag <img src="" alt=""> is used to embed images in a document. The attributes src and alt are required!

<img src="images/red_panda.jpg" alt="Panda czerwona" />

More about the <img> tag: link
link

Note: It is assumed that in the current folder (i.e. the folder where this HTML document is located) there is a subfolder named “images” that contains the JPEG image.

Place the editor’s photo (in JPG format) below the heading.


lab1

Including very high-quality images will significantly reduce the performance of processing an HTML document by the browser.

The <p> tag indicates that a section of the document is a paragraph. This means its content is thematically connected and a space will appear between it and other elements when rendered.

link
link

<p>Content of the paragraph.</p>

Use this tag to create a description of the editor below the photo. The description should contain more than 600 characters.


lab1

The <hr> tag (horizontal rule) indicates that a topic change occurs in the further part of the document.

link
link

Add a new editor and then separate the content concerning individual editors with the <hr> tag.


lab1


Task 3.

Example list:


lab1

Lists are created by defining a root element using <ol> (ordered list) or <ul> (unordered list). Then, within the element, define list items using <li> tags.

<ol>
  <li>element 1</li>
  <li>element 2</li>
  <li>element 3</li>
  <li>element 4</li>
  <li>element 5</li>
</ol>
<ul>
  <li>element 1</li>
  <li>element 2</li>
  <li>element 3</li>
  <li>element 4</li>
  <li>element 5</li>
</ul>

To create a nested list, define a new list within a list item:

<ol>
  <li>element 1</li>
  <li>element 2</li>
  <li>
    element 3
    <ul>
      <li>element 1</li>
      <li>element 2</li>
      <li>element 3</li>
      <li>element 4</li>
      <li>element 5</li>
    </ul>
  </li>
  <li>element 4</li>
  <li>element 5</li>
</ol>

link
link
link
link


Task 4.

Create a heading “Terminarz Wydarzeń” (“Event Schedule”) and then create a table related to events that are thematically linked to the website’s title. When creating the table, use the attributes colspan (to merge columns) and rowspan (to merge rows) to combine cells appropriately.

Example table:


lab1

Example table code:

<table border="1">
  <thead>
    <tr>
      <th>Column 1 Header</th>
      <th>Column 2 Header</th>
      <th>Column 3 Header</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Row 1 Header</th>
      <td>cell 1</td>
      <td>cell 2</td>
    </tr>
    <tr>
      <th>Row 2 Header</th>
      <td>cell 3</td>
      <td>cell 4</td>
    </tr>
  </tbody>
</table>

<table border="1"> – the main tag within which the table structure is defined.
The border attribute is added solely for demonstration/testing purposes to show the table’s appearance. THE BORDER ATTRIBUTE SHOULD NOT BE USED ACCORDING TO THE CURRENT HTML SPECIFICATION!

<thead> – groups the table header.
<tbody> – groups the table body elements.
<tr> – defines a table row, within which cells are defined.
<th> – defines a header cell.
<td> – defines a data cell.

Rows and columns are merged using the attributes rowspan and colspan added to the cell tags. When merging cells, specify the appropriate number in that dimension.

<table border="1">
  <thead>
    <tr>
      <th>Column 1 Header</th>
      <th colspan="2">merging two headers</th>
      <th>Column 4 Header</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Row 1 Header</th>
      <td>cell 1</td>
      <td>cell 2</td>
      <td>cell 3</td>
    </tr>
    <tr>
      <th>Row 2 Header</th>
      <td>cell 4</td>
      <td>cell 5</td>
      <td rowspan="2">merging two cells in a column</td>
    </tr>
    <tr>
      <th>Row 3 Header</th>
      <td>cell 7</td>
      <td>cell 8</td>
    </tr>
  </tbody>
</table>

link
link


Task 5.

The <footer> tag designates a section of the document where additional information is provided, such as contact details, copyright information, links to other sites, and other details.

Using the knowledge you have acquired about HTML, create a document footer that correctly uses the following tags:

Use character entities to represent copyright:

link

Before UTF-8 became widespread, entities were necessary to represent special characters. Nowadays, they are more often used to correctly display the characters < and >, which can easily be confused syntactically with the beginning/end of tags.


Task 6.

Familiarize yourself with the documentation of the following tags:

link

Then write a paragraph that correctly utilizes the following tags:

Compare the rendering results of the following tags:

What can you say about them?


Task 7.

Organize the page content using the following tags:

For each second-level heading, add a unique id attribute. Then create a menu consisting of hyperlinks to the respective headings.

Hyperlinks can refer to headings by defining the href value as #[id of the tag]:

<a href="#heading">Go to the heading with id "heading".</a>
<div style="display: block; height: 5000px;"></div>
<h2 id="heading">Heading with id "heading"</h2>

Below is the complete translation for Task 8 and the remaining content:


Task 8.[*]

Create a document that serves as your first blog post. Use the knowledge you have acquired to generate the blog entry content, include images, and add an interesting fact. The interesting fact should be defined using the <details> and <summary> tags.

link
link

Also consider using the following tags: