Week 41
Week 41
Week 4
Page Structure& Sectioning/ Grouping
Content
Agenda
Block Elements vs. In-Line Elements
Semantic vs. Non-Semantic Elements
Sectioning Content
Basic elements for textual markup
Hyperlinks
Absolute and relative URLs/paths
Images
Demo& Publishing
2
Block Elements vs. In-Line Elements
Block elements begin on a new line and end with a
line break. They take up the full width of the screen
(unless you've defined otherwise with CSS).
● paragraphs are block elements.
In-Line elements don't start on a new line and don't
contain a line break at the end, and they follow the
regular flow of the document. They only take up as
much space as they need
● Links are in-line elements
3
Examples
Are these elements block or in-line elements?
● <h1>
● <address>
● <div>
4
Semantic vs. Non-Semantic Elements
When HTML5 was released in 2014, it included a set of
new semantic elements, which add more meaning to a
web document.
● Semantic elements are HTML elements whose
6
Semantic Elements
Semantic elements are accessible according
to the WCAG and WAI-ARIA guidelines.
It's important to always use the appropriate
semantic element that is most appropriate Accessibility
and not use generic elements that have no
meaning (unless the meaning isn't
important).
You should never use a semantic element for
any purpose other than the one it's intended
for
7
Examples of Semantic Elements
Here are a few of the common semantic elements
● <header> - the document header, but can also
tutorial, etc.
8
Non-Semantic Elements
We still use non-semantic elements for some parts
of a page or application.
It's important that you don't use semantic elements
for any purpose other than the purpose for which
they were intended.
9
Examples of Non-Semantic Elements
<p> element is a general paragraph: it's not a paragraph of
a blog post, article, sidebar, etc.
<div> element is a block element that can contain any
text, and it's often used as a container for other elements.
We still use <div> and <span> elements to contain
content that we want to style a certain way or that doesn't
really fit with any of the semantic elements.
It’s bad to use a <section> element for a document
footer or a <footer> element for anything that's NOT a
document footer.
10
Example
Can you guess what ● <details>
these elements are for,
● <nav>
● <summary>
just by the element ● <time>
name: ● <menu>
● <form> ● <abbr>
● <table> ● <audio>, <video>
● <figure>, <figcaption> ● <picture>, <img>
● <input> ● <address>
● <button>
11
Sectioning Content
Semantic containers:
● <header>
● <article>
● <main>
● <section>
● <nav>
● <footer>
● <aside>
12
Basic elements for textual markup
13
Hyperlinks
A hyperlink is a bit of text that is clickable with a
mouse. Clicking the link usually requests a different
document (the name and location of the document
is part of the link's information): your browser will
receive the requested document and load it in the
viewing area for you.
If the requested document is not found on the
server, the server will send back the 404 NOT FOUND
error page
14
Hyperlinks
Links can do more than just request a new
document: they can also trigger scripts (such as
JavaScript).
We can create links on a page with the <a> element.
The name and location of the page/file is defined in
the anchor element's href attribute.
<a href="https://developer.mozilla.org/en-
US/docs/Web/HTML/Element/a">the Anchor
element</a>
15
Example
Choose three of your favourite web sites. Copy the
URLS and use them to create three links inside a
single paragraph element, one per line. Include a
description for each link.
16
Absolute and Relative URLs/Paths
An absolute path or URL will work from anywhere:
<a href="https://terminallearning.com/devHtml/index.html">Main HTML
Index</a>
18
Images
In HTML, we display images using the <img>
element.
<img> is an in-line element, so it will flow with the
rest of the document, it will not show up on a line by
itself if you surround it with text or other in-line
elements
Images are often placed inside the semantic element
19
Images
To identify which image you'd like to display, you use the <img>
element's src attribute (short form for "source", as in, the source
of this image). Assuming your image is in your project's /images
directory, you can use a relative path to your image, such as:
<img src="images/myImage.jpg">
Define "alternative text“ through the alt attribute, this is useful
when:
● The image can't be loaded
● A user is using a screen reader:
<img src="images/myImage.jpg" alt="photo of a
thing with a thing">
20
Images- Reminders!
When you're hosting your own images on your server don't
forget to:
21
Images
There are several places where you can find public
domain images that are free to use with no or very
few concessions:
● UnSplash
● Wikimedia Commons
● Flickr Commons
● Magdeline
● The Noun Project
● Pexels
22