LanguageHTML
LanguageHTML
Think of a document that you would create in a word processor like Microsoft Word
or Google Docs. They usually consist of more than one style.
They use different font sizes to indicate different section of the text, like headers,
body paragraphs, footers, table of contents, captions, and so on.
Unlike humans who can simply look at a document and understand the difference
between a heading and a paragraph, computers don’t have that intuition. In order to
correctly render a web page, it must be explicitly told what each piece of content is.
So how exactly do we instruct the browser to display web content? This is where
Hypertext Markup Language(or HTML for short) can come in handy.
HTML is the language in which most websites are written with. It is used to create
web pages and ensure their functionality.
HTML allows you to take a plain text document created in any simple text
editor and organize it into lists. It also creates links to other webpages,
includes images, and much more.
Just like most programming languages, we type a bunch of HTML into a file
(aka. document) so we can send it around.
HTML documents are files that end with a .html or .htm extension. You
can view them using any web browser (such as Google Chrome, Safari, or
Mozilla Firefox). The browser reads the HTML file and renders its content
so that internet users can view it.
True
False
HTML elements are represented by:
HTML Elements
<> tags
Web pages
HyperText defines the link between web pages:
True
False
True False
The part written in the head tag is visible to the user.
True False
Remember the folder structure that we have talked about in the previous
chapter? It’s time to use it.
Inside the GoMyCode folder, we are going to create a file
named index.html
Assessment: Quiz
Tags that can be closed are called unpaired tags.
True False
This is the right way to write a comment <!-- comment -->
True False
The comment is visible to the user.
True False
The HTML tag:
As we have seen earlier, everything is contained inside the < html
> tag.
It is a crucial tag. It tells the browser that the content is
located between < html > and < /html>.
It is also called the “root” element.
<html>
<!--Everything-->
</html>
Assessment: Quiz
Everything is contained inside <html> tag except for the links.
True False
The html tag is an unpaired tag.
True False
The html tag is called the root element.
True False
All web pages have one single body element, in order to understand the
tags inside the body, we will divide them into:
Headings
Text Formatting and Line Breaking Tags
Paragraphs
Images
Audio and Video
Links
Lists
Tables
Buttons
Forms and Inputs
</head>
The head element contains information about the web page. You can put
many elements inside of it such as:
Title => Sets the title of the page
Link => links elements to html, such as the page icon, CSS files...Etc.
We will see the other tags later on in the course.
Here’s an example down below,” rel” and “href” are called tag attributes,
we will get back to them later in the course.
For now, to set the icon, you need to set rel to “icon” and href to the link
to your image.**
This is a h1 Heading
<h2>This is a h2 Heading</h2>
This is a h2 Heading
<h3>This is a h3 Heading</h3>
This is a h3 Heading
<h4>This is a h4 Heading</h4>
This is a h4 Heading
<h5>This is a h5 Heading</h5>
This is a h5 Heading
<h6>This is a h6 Heading</h6>
This is a h6 Heading
Solution
Order The heading tags from the most important heading to the least important
heading.
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Paired tag:
This is a <b>bold</b> tag test
This is a bold tag test
This is an <i>italic</i> tag test
Paired Tags: ( if the text is placed between a tag and its companion
tag.) Example :
<b>: Bold Text
<i>: Italic Text
<small>: displays smaller text
<del>: defines deleted text
Note: HTML doesn’t read spaces, you need to use <br> to jump a line
Paragraph Tag:
The < p > Tag defines a paragraph in HTML.
the browser breaks a line without the need of the < br> tag.
Paragraphs are automatically separated by a line break.
It's similar to writing a paragraph in a word document, paragraphs need to
be separated from each other for them to be coherent and
understandable.
Here’s an example :
<p>My first paragraph</p>
My first paragraph
My second paragraph
Hello, World!
True
False
Every html tag can only have one attribute.
True
False
To alter the text To be the back-up plan,if the image fails to load
The src attribute is responsible for
Determining the source of the image Determining what will be displayed if the
resource loading fail Styling the image
The img tag is called
Paired Unpaired
Links Tag
Linked page
One of the most important aspects of the World Wide Web is the ability to
connect with other parts of the web.
Without a method to redirect our HTML page to other web addresses, the web as
we know it would cease to exist.
We can connect a HTML page to other web pages by creating a hyperlink using
the anchor tag.
The a tag:
<a href="https://gomycode.tn/">Take me to GoMyCode's Website</a>
Links allow users to navigate between different web pages. If you click on
a link , you can jump to another document.
Links are defined with the < a > tag also called anchor element.
The “href” attribute defines the path once it’s clicked on.
Internal link:
Links can be local links too. It will allow users to navigate on the same web
page,
In other words you can click on a link and jump to the end of the page, or
to an element on your web page.
<body>
<h1>Link Up Top</h1>
<p>
</p>
<p>
Quia, consequuntur!
</p>
</body>
This is what it should look like. As previously mentioned, local links makes
it easier to navigate in your web pages.
a ahref asrc
The “href” attribute defines:
the reference to the code the path once clicking. reference to the browser
Why we use local links?
to allow users to navigate in the same web page to navigate between different
web pages To navigate without using the internet
Audio//Video tag:
The audio tag:
To play an audio html file, use the < audio > element:
The controls attribute is necessary. It adds audio controls like play, pause,
and volume control.
The < source > element allows you to specify alternative audio files from
which the browser can choose from.
The browser will use the first recognized format.
The text between < audio >< /audio> will be displayed only if the audio
file is not supported by the browser.
<audio controls>
</audio>
</video>
width="420"
height="315"
src="https://www.youtube.com/embed/zcTFG_F0FRs"
></iframe>
True False
The src attribute in the video tag replace the <source> tag
True False
Lists Tag :
HTML lists :
Lists are used to arrange related pieces of information so they are
connected, understandable and easy to read. In modern web
development, lists are workhorse elements, frequently used for navigation
as well as general content.
Lists are advantageous from a structural point of view as they help create
a well-structured, highly accessible, and easy-to-maintain document. They
are also useful because they provide specialized elements to which you
can attach CSS styles. Finally, semantically correct lists help visitors read
your web site, and they simplify maintenance when your pages need to be
updated.
There are many types of list. Let's have a look at the most used ones:
Ordered list
Unordered list
Description list
Unordered list:
To create an unordered list, we use the html tag <ul> typically rendered
as a bulleted list but we can change the style of the list using
the type attribute. Every element of the list is wrapped with tag <li>
<h1>Web Languages</h1>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
</ul>
Web Languages:
HTML
CSS
JS
<ul type="disc">
<li>AI Track</li>
<li>Web Track</li>
<li>Game Track</li>
</ul>
<ul type="square">
<li>AI Track</li>
<li>Web Track</li>
<li>Game Track</li>
</ul>
Ordered List:
The HTML <ol> element represents an ordered list of item, typically
rendered as a numbered list but like the unordered list it can be changed.
<h1>Web Ordered Languages:</h1>
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
</ol>
Ordered list type values can be used to change the numbering scheme,
and include the following:
<ol type="I">
</ol>
Description list:
The HTML <dl> element represents a description list. The element
encloses a list of groups that contain terms (specified using
the <dt> element) and descriptions (provided by <dd> elements). The
common uses for this element are: implementing a glossary or displaying
metadata (a list of key-value pairs).
<dl>
<dt>House Stark</dt>
<dd>The Direwolf</dd>
<dt>House Lannister</dt>
<dd>The Lion</dd>
<dt>House Targaryen</dt>
<dd>The Three-Headed Dragon</dd>
<dt>House Baratheon</dt>
<dd>The Stag</dd>
</dl>
Assessment: Quiz
Unordered Lists are represented by:
ol un ul ui
Ordered Lists are represented by:
on oi ol oli
Each element of the list is represented with
il li ul
True False
Div tag:
<div> is certainly one of the most useful tags in HTML.
The <div>, a block-level element,like a component, or a bag. It can contain
many HTML elements in order to apply changes on them as a whole
section.
</div>
<div>
</div>
Table Tag
Table
There are plenty of situations where you’ll want to present a table of data
on your web page.
If you haven’t worked with tabular data before, it will be useful to know
that a table consists of rows and columns. Each row/column pair has a
piece of data corresponding to it, referred to as a table cell.
Let’s dive straight in and convert the table below into HTML.
HTML CSS JS
<nav>
</nav>
Section tag:
The <section> element defines a section in a document.
For example, if we want to split our home page into several sections for:
introduction, content, and contact information, etc...
<section>
</section>
Article tag:
The <article> element defines an article in a document.
</article>
Aside tag:
HTML offers many semantic elements to define distinct parts of a web
page.
HTML Forms
<head>
</head>
<body>
<form>
A form
</form>
</body>
</html>
Quick look
Here’s a quick look on how a form would look like using only HTML. Don’t
mind the tags inside the <form> , we are going to have a closer look at
them later.
<form>
<label>Name:</label>
<br />
<label>Number:</label>
<br />
<label>Birth Date:</label>
<label>Password:</label>
<br />
</form>
Assessment: Quiz
Form is a way to display data for users:
True False
To create a form, we use the tag <form>
True False
The <form> tag is the only necessary tag to get the user’s inputs
True False
</form>
Output
As seen in the code above, there is a type and name associated with inputs.
The type defines the nature of the input (text, URL, email,...), while
the name allows us to access the input data for future use. You can think of
the name as a variable in which the input data is stored. Other properties
of input include:
size
value
maxlength
readonly
Selection inputs
You can use <select> (with nested <option>) elements to create a drop-
down selection of items that a user can choose from.
<select>
</select>
Text area:
If you want your user to be able to include new lines (by pressing return)
in their text input, you can use a <textarea> element:
The rows attribute specifies the visible number of lines in a text area.
The columns (cols) attribute specifies the visible width of a text area.
<textarea name="message" cols="30" rows="5">
Welcome to GoMyCode
</textarea>
Buttons:
A <button> element should be used whenever you want to create a
clickable button to perform a certain action on the page.
<button> elements are simple to define, and have three different type
values:
But, if you take a look at the end product, you will find that it’s still quite
far from an actual web page. We have developed a static, unattractive
web page with no aesthetic or forms output.
Right now, our number one priority is to solve that problem, and then we
will start adding polish, style and elegance to our web page.
CSS
What is CSS?
As we have mentioned, in this chapter we are going to be focusing on
style, presentability and the appearance of our webpage. The main
language used for styling a web page is CSS.
What is CSS?
How to integrate CSS into HTML?
How to select an HTML element?
How to change the position of an element?
CSS determines the look and feel of a web page. With CSS, you can
control the color of a text, the style of fonts, the spacing between
paragraphs, how columns are sized and laid out. It also defines what
background images or colors are used, the layout designs, and most
importantly, the variations in display to adapt to different devices and
screen sizes.
CSS is easy to learn and understand but it offers powerful control over the
presentation of an HTML document. Most commonly, CSS is combined with the
markup language HTML.
=> HTML describes the structure of the webpage while CSS describes the
way it should be displayed on the screen.