The Best Introduction to HTML, CSS and JavaScript (Part 3)
CSS and JavaScript Up Next:
Congratulations, you are reading this; here’s a continuation of our coding journey on Introduction to HTML, CSS, and JavaScript. In this tutorial, we will take another step further on our coding journey.
I’ll go further with our learning curve, and we have a unique topic today. Hi, welcome to our last class on HTML, To avoid missing any subsequent classes, kindly follow me. If you’ve missed the previous lessons we’ve had or want to refresh your memory, click here.
Congratulations, you are seeing this Tweet. Kickstarting your career in Tech has been fruitful as we will be coming to the end of HTML after today’s class
Course: HTML, CSS & JAVASCRIPTS
Again I will break this down like you are 4 years old, kindly retweet for others, and join.
— Àgbà Akin (@Kynsofficial) January 7, 2022
Each HTML element is interpreted in a specific way by your web browser. Now that you’ve started to learn about structuring your web pages, we should discuss the differences in block-level and inline HTML elements to gain a better understanding of how content is rendered
HTML Inline vs Block Element and DIV
Your web browser interprets each HTML element uniquely. Now that you’ve begun to learn about web page structure, we should go through the distinctions between block-level and inline HTML components to better understand how information is displayed.
Block-level elements
A block-level element always begins on a new line, and browsers provide space (a margin) before and after the element.
A block-level element always takes up the whole available width (stretches out to the left and right as far as it can).
The block components <p> and <div> are two of the most widely utilized.
In an HTML page, the <p> element specifies a paragraph.
In an HTML document, the <div> element establishes a division or segmentation.
- Headings (<h1> all the way to <h6>)
- Ordered and Unordered Lists (<ol>, <ul>)
- List Items (<li>)
- Paragraphs (<p>)
Here are the full list of block level elements
<address>
<article>
<aside>
<blockquote>
<canvas>
<dd>
<div>
<dl>
<dt>
<fieldset>
<figcaption>
<figure>
<footer>
<form>
<h1>-<h6>
<header>
<hr><li>
<main>
<nav>
<noscript>
<ol>
<p>
<pre>
<section>
<table>
<tfoot>
<ul>
<video>
Inline Elements
As the name implies, inline elements do not take up the whole width of a web page and are often aligned with text content.
<span>Span element is an example of inline elements</span>
Inline components include the following:
- Anchors (<a>)
- Images (<img>)
- Bolding Text (<strong>)
- Emphasizing Text (<em>)
<a>
<abbr>
<acronym>
<b>
<bdo>
<big>
<br>
<button>
<cite>
<code>
<dfn>
<em>
<i>
<img>
<input>
<kbd>
<label>
<map>
<object>
<output>
<q>
<samp>
<script>
<select>
<small>
<span>
<strong>
<sub>
<sup>
<textarea>
<time>
<tt>
<var>
Note: An inline element cannot contain a block-level element!
Divs
The <div>, a block-level element, allows you to section into.
It is often used to encapsulate additional HTML components.
There are no necessary properties for the <div> element; however, style, class, and id are popular.
The <div> element may be used to style content blocks when combined with CSS:
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
The <span> Element
The <span> element is an inline container that is used to mark up a section of text or a section of a page.
There are no necessary characteristics for the <span> element; however, style, class, and id are popular.
In summary, there are two types of display values: block and inline.
- A block-level element always begins on a new line and occupies the whole available width.
- An inline element does not begin on a new line and only takes up as much space as is required.
- The <div> element is a block-level element that is often used to hold other HTML components.
- The <span> element is an inline container that is used to mark up a section of text or a section of a page. When used with CSS, the <span> element may be used to design sections of text like follows:
HTML Selectors
HTML Selector (type, class & id)
- Type
- Class
- id
The id attribute provides you with the ability to give any element a unique identifier. This identifier can later be used to apply specific styles with CSS or capture input with some Javascript code.
- an id value should only be used for a single element (you will get unexpected behavior if you use the same id value for multiple elements)
- an id value must not contain any whitespace. The class attribute is similar to the id attribute in that it is used to identify specific elements. The main distinctions are:
- the same class value can be used across multiple elements •an element can have multiple class values, separated by whitespaces
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
Class selector for Exp <h1 class= “twitterUser”> Kynsofficial </h1>
for type selector. You will learn about it in CSS.
<!-- Incorrect img declaration -->
<img src="kynsofficial.jpg" alt="A cat"></img>
<!-- Correct img declaration -->
<img src="kynsofficial.jpg" alt="A cat">
Html Semantics
HTML SEMANTICS
In this lesson, we will address the importance of considering semantics when structuring your HTML pages.
A semantic element expresses its meaning unambiguously to both the browser and the developer.
Non-semantic elements include <div> and <span>, which reveal nothing about their content.
<Form>, <table>, and <article> are examples of semantic components that clearly specify their content.
So far, we’ve emphasized utilizing HTML to organize our web pages and show the material in a particular way. With the HTML5 standard, several new components were added, shifting HTML from a presentation-centric to a more semantic-centric approach.
Many web sites contain HTML code like: <div id=”nav”> <div class=”header”> <div id=”footer”> to indicate navigation, header, and footer.
In HTML there are some semantic elements that can be used to define different parts of a web page:
- <article>
- <aside>
- <details>
- <nav>
- <section>
- <summary>
- <time>
- <figcaption>
- <figure>
- <footer>
- <header>
- <hgroup>
- <main>
- <mark>
Let us explain some of them
hgroup
<hgroup>
<h1>My Amazing Website</h1>
<p>More information about my website</p>
</hgroup>
header
Many web page headers include logos and huge headlines that identify the site. The <nav> elements should be used to hold your page’s navigation components.
<header>
<hgroup>
<h1>My Amazing Website</h1>
<h2>More information about my website</h2>
</hgroup>
<nav>
<!-- Navigational anchors elments are often wrapped in an unordered list -->
<ul>
<li><a href="aptlearn.com/contact">Contact Me</a></li>
<li><a href="/about">About me</a></li>
</ul>
</nav>
</header>
Footer
<footer>
<h3>© aptLearn, United Kingdom, 2017</h3>
</footer>
article
<article>
<h1>Cryptocurrency: What is it?</h1>
<!-- Article contents -->
</article>
section
<section>
<h2>Chapter 1</h2>
<!-- Chapter contents -->
</section>
<section>
<h2>Chapter 2</h2>
<!-- Chapter contents -->
</section>
<section>
<h2>Chapter 3</h2>
<!-- Chapter contents -->
</section>
<section>
<h2>Chapter 4</h2>
<!-- Chapter contents -->
</section>
time
<!-- time of an event -->
<p>The party begins at <time datetime="19:00">seven o'clock</time>!</p>
<!-- date of publication -->
<h1>My Blog Entry</h1>
<h2><time datetime="2015-05-07">May 7, 2015</time></h2>
Exercise 1
HTML Table
HTML TABLE
There may be times when you’ll wish to display a table of data on your website. Let’s get started by converting the table below to HTML.
If you’ve never dealt with tabular data before, it’s helpful to understand that a table is made up of rows and columns.
Example
<table></table>
<table>
<tr></tr>
</table>
<table>
<tr>
<td>first 1</td>
<td>second 2</td>
<td>third 3</td>
<td>fourth 4 </td>
</tr>
</table>
HTML Table Tags
Tag | Description |
---|---|
<table> | Defines a table |
<th> | Defines a header cell in a table |
<tr> | Defines a row in a table |
<td> | Defines a cell in a table |
<caption> | Defines a table caption |
<colgroup> | Specifies a group of one or more columns in a table for formatting |
<col> | Specifies column properties for each column within a <colgroup> element |
<thead> | Groups the header content in a table |
<tbody> | Groups the body content in a table |
<tfoot> | Groups the footer content in a table |
See the complete list here.
Creating Forms in HTML
HTML FORMS HTML
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
Looks like magic? don’t worry, it is simple, lets break it down
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
Notice if you write in the password field, the text is obscured since we’ve indicated that the <input>’s type attribute has a password value. With this example in mind, let’s dive in and look at the variety of information we can use with HTML forms.
Do you also notice the rectangular lines around the form, that is to give it a fine outlook and it was done with <fieldset> tag
Text inputs
- text: for plain text
- password: to obscure a password input field
- Search: to indicate the text field is used for searching a page/multiple pages
- url: validates input as a URL address
- tel: for inputting phone numbers
- email: validates input as an email address
textarea
<html>
<head>
<title>Textarea Elements</title>
</head>
<body>
<form>
<label for="multiLineInput">
<p>This is an input element that can include new lines:</p>
<textarea id="multiLineInput"></textarea>
</label>
</form>
</body>
</html>
<html>
<head>
<title>Textarea Elements</title>
</head>
<body>
<form>
<label for="multiLineInput">
<p>This is an input element that can include new lines:</p>
<textarea rows="5" cols="50" id="multiLineInput"></textarea>
</label>
</form>
</body>
</html>
Let’s move…
HTML Buttons
Buttons
- submit: submits form data to a server
- reset: resets all the data in the current form
- button: no default behavior. This type of button will be more useful when we begin our discussion of Javascript.
<html>
<head>
<title>Reset Button</title>
</head>
<body>
<fieldset>
<form>
<label for="firstName">First Name:</label>
<input type="text" name="firstName" id="firstName">
<label for="lastName">Last Name:</label>
<input type="text" name="lastName" id="lastName">
<!-- This button will reset the form -->
<button type="reset">Reset Button</button>
</form>
</fieldset>
</body>
</html>
A clickable button is defined using the <button> tag.
Text (including tags like <i>, <b>,< strong>, <br>, <img>, and so on) may be placed within a <button> element. That is not feasible with an <input> element-created button!
Always include the type property with a <button> element to alert browsers what sort of button it is.
Let’s Style the buttons using a little bit of CSS
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
let’s add hover effect to the created buttons
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
Hope you enjoyed this, let’s move, we are almost done
HTML Checkbox
Check Box
Definition and Application
A checkbox is defined by the <input type=”checkbox”>.
When active, the checkbox appears as a square box that is ticked (checked).
Checkboxes are used to allow a user to pick one or more selections from a restricted set of possibilities.
For optimum accessibility standards, always include the <label> tag!
See example below
See the Pen
Untitled by aptLearn (@aptlearn)
on CodePen.40347
Perfect, everything you’ve learned so far is fundamental, enough to give you a great headstart in your quest to become a pro in web development.
Keep this in mind that you cannot learn it all from one place or one tutor, you need a combination of different resources to become the pro that you so admire to be. so check below for my recommendations
Learn HTML further here
Nice write up, I didn’t get the part of adding images, will be glad if you can respond to this, thanks
Same here
You can do a little research on Google. To be good at this, you need to learn how to search
If the image is downloaded on your PC, rename the picture to something you’ll remember (e.g Old Trafford); copy it to the folder you created for this HTML course. Then in your code;
Thank you. This was actually very helpful
Hi,
How can I send in all what have been able to do from lesson 1 till date?
Thank you.
Hello,
Yes why not?
I dropped a tweet tagging you, since you are more available there on the go.
Kindly make some of the screenshots of the lessons visible better. They are narrow and hence i could not know how your text area was larger and better aligned than mine. I did it though just that it wasn’t aligned.
Thank you
Thanks for your input, I will Improve on that
Thank you very much
Well done Sir, please i also tried adding image myself but it’s not coming up, I copied the link also tried coping the address of the image on my gallery too still isn’t up
Please could you kindly make the screenshots of the lesson full image? Most of them are half and I could not see the remaining texts
Please could you kindly make the screenshots of the lesson full image? Most of them are half and I could not see the remaining texts
Well done sir. I am an ardent follower of your class on twitter, albeit a silent one. It seems you recently unpinned the tweet of the classes you started around November, 11, 2021. I do visit those classes from time to time and i will be glad if i can get a link to the classes. God bless you.
the images are not showing
That will get fixed do not worry.
Hello, I really appreciate you effort. Please can you include the images of what you’re talking about just like you did in previous classes. It helps me understand better thank you.
Good afternoon! Please is phone limited, coz I seem not to understand how to add an image to the HTML sir. This has been disturbing sir. Can a phone do that or I just need to get a pc
Hi Jul, just copy the code. A phone can do it.
How do I copy the code on an iPhone please?🙏🏽
What code exactly??
Definitely saving all these codes on my sololearn, and the write up on my note pads also , thank you for everything Agba Akin, it’s me and tech this year
Let us do this.
Hi there, I did everything as instructed by my image did not display when I ran the code. fyi I copied the image address from google, is this the reason for it not running? if yes how and where then do we get images from. I was able to right click on it and see the image on a different tab tho (alt came in handy lol).
Pls am finding it difficult to add image
Done with the html class.
What a great lecture well detailed.
Thank you sir.
Now ready to start with CSS on Monday.
Finally finished, thanks again for this wonderful class🙏🏽
Hello good sir
Nassur here. taking your classes all the way from Kenya. Thank you so much for all the good great work your doing. God bless.
I notice you haven’t taught us how to change the web address of our website that were creating from html. when we go live, it reads some other things rather than say (www.nassur.com)
Something for my log book… Thanks!
Great teaching! Thank you Sir.
My form is not appearing like yours, i.e. the boxes and names are on the same line…. Surname (box) First name (box) Submit (box), instead of…
Surname (box)
First Name (box)
Submit (box).
Use the div tag to break the form to the next line.
What about the br tag for this purpose
Thank you very much for this
I used to be have rusty knowledge about forms but now am better
Thank you so very much for the classes.
I’m having a little issue. My form is coming out horizontally, instead of vertically
Oh. I get it now. I just watched the video. You did CSS to make it look vertical and beautiful
Submit Button
First Name:
Last Name:
Submit Name
Where will the submit button be direction to? Can I choose where I want it to be directing to?
Nice Tutorial
Simply want to say your article is as amazing.
The clearness on your put up is just spectacular
and i could assume you are knowledgeable in this
subject. Fine with your permission let me to take hold of
your RSS feed to keep updated with impending post.
Thanks one million and please continue the gratifying work.
Hi! Do you use Twitter? I’d like to follow you if that would be okay.
I’m definitely enjoying your blog and look forward to new updates.
you’re in reality a good webmaster. The site loading speed
is amazing. It sort of feels that you are doing any unique
trick. Moreover, The contents are masterwork.
you’ve performed a wonderful activity on this
topic!
so greatful…..am loving this
I had problem on the first and last name including the radio button,both their space lies side by side instead of being in accordance like yours
Thanks for your awesome class Agba…
may you be blessed beyond measures.Aameen
Thanks for all you do AGBA AKIN.
You’re a blessing to our generation.
I have been following your class for days now, and I am glad I came across someone like you to teach coding for free. God bless you.
I have a question, I am wondering how I was able to paste your code on my sololearn app and it still displayed Ronaldo’s picture, please can you shed a little light on that because I have googled it and the result I am having is that I must download the pictures and upload first, but your code I didn’t download the picture, I just copied your code and paste it on my sololearn and it displayed the picture and when I copied just the link of the image and paste it on chrome it displayed the picture also but when I deleted one word form the link it displayed error.
I will be glad if you answer my question.
Thanks once again
How can I prevent The radio and checkboxes from selecting multiple options as response
How can I add borders to the table to give it more shape sir