text tags: <p> and <br>¶
observe that newlines do not matter in HTML source code, usually they are treated as spaces
grouping: <div> and <span>¶
one very common tag is
<div>it is used to group together elements inside a single node
<div>stands for division
there is also
<span>that serves a similar purposeexcept for the linebreaking behaviour
they are an essential tool in any page design
<div> and <span> example¶
what with the style thing ?
style thing ?this example uses styling - that we have not studied yet - to outline the <span> and <div>
elements by changing their background color
second example of <div>¶
there is also <section>¶
the <section> tag also provides grouping capabilities, but with a more semantic meaning
for example your CV will probably end up with e.g. 5 sections (header, education, experience, skills, languages)
however if your layout is sophisticated enough, you will probably end up with more than 5 divs, that are just there for layout purposes
other semantic sectioning tags
other tags related to semantic sectioning: <body>, <nav>, <article>, <aside>, <hgroup>, <header>, <footer>, <address>, as well as <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, that we will see later on
lists: <ul> <li> and <ol>¶
code-like: <pre> and <code>¶
<pre>stands for preformatted (line breaks and spaces are kept as-is)<code>is for a terminal-like font and style
links and anchors: the <a> tag¶
the anchor tag <a> serves two purposes :
→ create a hyperlink that can bring users to another location
← create a name locally so that this particular location can be the target of a hyperlink
hyperlink <a href="some-url">¶
typical hyperlink reads like this
name anchor <a name="some-name">¶
if you need a hyperlink to point, not at the beginning of this page, but somewhere in the middle, then create an anchor at that location
URL to an anchor¶
you can then refer to that anchor from any other webpage using a URL that ends with
#the-anchor-nameso if this page is published as
https://example.com/some/page.htmlthen you can create a direct access to the magic location
with a
<a href="https://example.com/some/page.html#the-anchor-name">
local URL¶
here’s an example of a page that has a named anchor (below the gray area) and a hyperlink to that location
do not worry about that gray blob for now
we have not yet seen how to create this gray thingy below, please admit it for now
<table>, <tr>, <th>, <td>...¶
use the <table> tag in to display tabular data (think, e.g. a spreadsheet)
historical note
in the early ages of HTML, tables were all over the place, for creating fancy layouts (e.g., a page that has several columns, side by side)
however, we strongly recommend that you do not use <table> for layouts,
especially if your goal is to create grid-based layouts, that we will cover later on
legacy tags¶
header tags <h1> .. <h5>¶
these tags are a bit old-school
these tags are essentially a legacy thing; they are convenient, but not quite necessary,
you can easily write your own classes (more about classes later on) to get a similar outcome, with more control on the result.
styling tags: <b>, <i>, <u>, <s>¶
for the record only (these dates back to the old days when HTML was mimicking a word processor...)
a handful of convenience tags for quick styling
like bold, italics, underline and similar