<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hildweig 🐬</title>
    <description>The latest articles on Forem by Hildweig 🐬 (@hiidweig).</description>
    <link>https://forem.com/hiidweig</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F401671%2Fa2549c77-1e39-4600-a84c-52a1e7a11407.jpg</url>
      <title>Forem: Hildweig 🐬</title>
      <link>https://forem.com/hiidweig</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hiidweig"/>
    <language>en</language>
    <item>
      <title>Simple guide for HTML forms</title>
      <dc:creator>Hildweig 🐬</dc:creator>
      <pubDate>Sun, 07 Feb 2021 23:16:04 +0000</pubDate>
      <link>https://forem.com/hiidweig/simple-guide-for-html-forms-4m32</link>
      <guid>https://forem.com/hiidweig/simple-guide-for-html-forms-4m32</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;How many websites users visit nowadays that doesn't have some sort of login or interaction with users? Imagine how boring websites would be if the only available content is the website's owner's content (Read-only)? If you couldn't comment nor like, if you didn't have an account, to begin with? HTML forms play a great role in enabling developers to easily create amazing interactive websites where users can purchase products, search for something, participate in surveys, and the list goes on. Now you surely realize how much these elements are necessary and the influence they have on the user experience, this is why you want to have a solid understanding of how to create them, and how to use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  General idea about forms
&lt;/h2&gt;

&lt;p&gt;In HTML the idea about forms is that you have a bunch of different forms elements available for you, and all of these are wrapped inside a big form container. You can have more than one form in your document, what is important is that your form elements are contained inside a form that serves a particular purpose. And to be able to send what users entered there is also a special element to send the data inside the form. Simple as that!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flr7cirjsw8to2klwavap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flr7cirjsw8to2klwavap.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you got the idea, let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The form container
&lt;/h2&gt;

&lt;p&gt;Your big form container is the &lt;code&gt;&amp;lt;form&amp;gt;&amp;lt;/form&amp;gt;&lt;/code&gt; element, it has an opening tag and a closing tag, and all your elements are in between. The form element has two attributes that you always need to have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;method: The method attribute tells the web browser how to send form data to a server. If you specify a value of &lt;strong&gt;POST&lt;/strong&gt;, this means that the browser will send the data to the webserver. You want to do that if you are sending sensitive data. If the &lt;strong&gt;GET&lt;/strong&gt; method is used, the data is sent inside the URL separated with a question mark. If you want to understand more about these methods I highly recommand you this &lt;a href="https://www.youtube.com/watch?v=iYM2zFP3Zn0&amp;amp;ab_channel=TraversyMedia" rel="noopener noreferrer"&gt;course&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;action: your forms are useless unless some kind of processing takes place after submitting. The action attribute helps us to specify where the data will be sent after the submission of the form, the value of the action is a URL. Simply put, after submitting your data will be sent and processed and the next page your user should access is the page that is specified in the action attribute!
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"get"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. The form elements
&lt;/h2&gt;

&lt;p&gt;HTML has a plethora of elements for basic things such as entering numbers, text, dates, email, password, as well as more complex elements such as menus, checkable elements, and so much more! Besides, for each of these elements, you can have some sort of validation that is already taken care of. So We have the flexibility to pick what suits us while a part of the troubles for the format etc is already handled. &lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 The input element
&lt;/h3&gt;

&lt;p&gt;The input element is the most commonly used form element because this element itself can "transform" and have a different behavior according to the type we specify for it to be. Look at this snippet and you will understand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"an_input_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the shape and behavior and the way you interact with that input are related to the type it has. For the sake of simplicity I will show you the ones you need most of the times:&lt;/p&gt;

&lt;h4&gt;
  
  
  Input to enter a username:
&lt;/h4&gt;

&lt;p&gt;When you want an input to enter a username, you can specify type="text", type="text" means that your user is allowed to enter any character but it has to be in a single line.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to restrict the length to a minimum or a maximum number of characters use minlength and maxlength attributes:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;minlength= &lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt; &lt;span class="na"&gt;maxlength=&lt;/span&gt;&lt;span class="s"&gt;"30"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you want to oblige the user to fill that field you can add the &lt;code&gt;required&lt;/code&gt; attribute, it just comes as a single word without a value, having it in your input means that it is required, if not then it is an optional field.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;minlength= &lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt; &lt;span class="na"&gt;maxlength=&lt;/span&gt;&lt;span class="s"&gt;"30"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;For a good user experience you can add a description about what that input is for, or the expected format, for that you can use the attribute &lt;code&gt;placeholder&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Enter username"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If your field is optional but you still want to have a default value, there is the attribute value, where you specify the default value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"UserHasNoName"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Of course, all these attributes work for different inputs not only the text type! And I gave you the username as an example, if you need to add a field to enter a single line text then this element is the most appropriate. You can see how these look here (spoiler alert: they won't look like a real form but we will eventually come to that):
&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/yLVORyG?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Input to enter an email
&lt;/h4&gt;

&lt;p&gt;The input of type "email" is the HTML element you should use for your email fields. It gives us the flexibility to control the format entered and ensure that it is valid, you can specify a minimum and maximum length, consider it required, change the pattern of the input that the email should follow... Just to say that it is perfect! You can also have a default value of course but I doubt you want to do that on a real-world website haha.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Enter your email"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The way you change the email pattern is by specifying a regular expression, simply put, it is a "string" that can match your text with that string content (like a decoder). If you want to know more about it I highly recommend you this &lt;a href="https://www.youtube.com/watch?v=rhzKDrUiJVk&amp;amp;ab_channel=WebDevSimplified" rel="noopener noreferrer"&gt;tutorial&lt;/a&gt;. And by the way, this attribute pattern also works for the input type of text, imagine if you have a country code with a specific pattern, this attribute is just perfect for more validation!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Enter your email"&lt;/span&gt; &lt;span class="na"&gt;pattern= &lt;/span&gt;&lt;span class="s"&gt;"your regular expression here"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Input for your passwords
&lt;/h4&gt;

&lt;p&gt;The input of &lt;code&gt;type="password"&lt;/code&gt; is a single text input that masks the characters for you while your user is typing (no need for extra-work to make it like that!). Same as for the email you don't want to have that field empty so I highly recommand you to use the required attribute, and most of the type you would find passwords of a minimum length of 8 characters, you can also add the maximum length attribute in case you have some troller that would type 999 characters as a password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"password"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Enter your password"&lt;/span&gt; &lt;span class="na"&gt;minlength=&lt;/span&gt;&lt;span class="s"&gt;"8"&lt;/span&gt; &lt;span class="na"&gt;maxlength=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffsi9s8uqjfvjxc7dbrme.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffsi9s8uqjfvjxc7dbrme.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Input for numbers fields
&lt;/h4&gt;

&lt;p&gt;If you want to ensure that the user can only enter numbers, use the input &lt;code&gt;type="number"&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The input type number has two nice attributes: min, and max, if your field concerns age and you don't want to have negative values then you can put the min ="0", same, for age if you want to have a maximum value that user can't exceed, you can add a default value with value ="your value", and make required if you want to and even have a placeholder, all what's available for inputs is available!
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"enter age"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3bd6fpihopysnnzu6map.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3bd6fpihopysnnzu6map.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can see that there is arrows, when you click on them you either add (+1) starting from 0 if you click on the upper arrow, or (-1) if you click on the other arrow, of course you can change how much you want to increase/decrease by specifying an attribute called step. You add it to your input and specify how much you want to "step". If I want to increase my values with 10 each time, then &lt;code&gt;step="10"&lt;/code&gt;, but once you reach the minimum you can't go bellow if min is specified, same for the max.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Enter quantity"&lt;/span&gt; &lt;span class="na"&gt;step =&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Input for dates
&lt;/h4&gt;

&lt;p&gt;You've probably guessed it, your input will have the type "date". Users will be able to enter the date either from a calendar that shows up as an icon or from a textbox. Say you are having a hotel website and your users can reserve rooms for some time, one of the things you would probably need is to restrict dates, it's weird if someone can reserve for yesterday, so same as the number input, you have a min and max attributes, excepts this time these are dates that follow this format: "yyyy-mm-dd".&lt;br&gt;
Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"date"&lt;/span&gt; 
       &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"2021-02-07"&lt;/span&gt;
       &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"2021-01-07"&lt;/span&gt; &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;"2021-12-31"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkqkj6fg57k28niri2a17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkqkj6fg57k28niri2a17.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The picture on the left is how it looked when I clicked on the year to change it, pretty nice right? I also added a default value assuming the reservation is for today in case the user doesn't change it.&lt;/p&gt;
&lt;h4&gt;
  
  
  Input for files!
&lt;/h4&gt;

&lt;p&gt;Yess, who guessed that we can upload files that easily! Just have the input with &lt;code&gt;type="file"&lt;/code&gt; and your users will be able to enter files in the field. You can also add the attribute multiple to be able to enter multiple files at the same time in the same field, it comes just as a single word, and having it there means that the multiple selection is activated. Also, you can restrict the types of files users can enter, if there is more than one then you can just separate them with commas (,).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"file"&lt;/span&gt; &lt;span class="na"&gt;accept=&lt;/span&gt;&lt;span class="s"&gt;".doc,.docx,.txt"&lt;/span&gt; &lt;span class="na"&gt;multiple&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzn1lxff422quxzgyawfs.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzn1lxff422quxzgyawfs.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Input for searching
&lt;/h4&gt;

&lt;p&gt;The search bars we see on websites are created using the input &lt;code&gt;type="search"&lt;/code&gt;, you can add a placeholder, a minlength or a maxlength if you want to, anyways here is an example!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"search"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"search"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flv07x57qnwqu6u6ng60h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flv07x57qnwqu6u6ng60h.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Input for choosing colors
&lt;/h4&gt;

&lt;p&gt;This one I found it twice or so on a website where the owner showed a beautiful Pomodoro with a cat and you can change the cat color and the background, it was pretty cool so even if it's not used that much I thought "why not?", you can add a default value using the value attribute if you want to. Here is how you can add a field to select colors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"color"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"#A5D9D6"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fva6cuwdquuhlcan6s7xp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fva6cuwdquuhlcan6s7xp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Checkboxes
&lt;/h4&gt;

&lt;p&gt;Checkboxes look like squares that users can "check". Let's say you have a list of toppings that clients can include in their pizza. They can select one or multiple toppings at the same time using checkboxes, and for each one, you would have something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"mushrooms"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"topping"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"mushrooms"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Mushrooms&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The first line is the input element, this is precisely our checkbox.&lt;/li&gt;
&lt;li&gt;Since you can't have any text with it (not even a placeholder), you need a way to show what that checkbox represents, and we do that using an element called "label". Most of the time, form elements are associated with a label element. The attribute "for" will link with the element by having the same value as the id attribute in the input. Besides, not only they are visually linked, but they are programmatically associated with it too. Another advantage is that, when you click on the label, you will automatically activate/focus on the input as well. If your users use a touch screen device, this will make things a little bit easier for them.&lt;/li&gt;
&lt;li&gt;The name attribute will help us to identify the data we send to the server. In fact, in all your form elements &lt;strong&gt;you should always add the name attribute&lt;/strong&gt;, I left it up to now to not condense the information, but now you know that in your elements you would have an id and a name too. The value of the name attribute can't be an empty string and should be unique, but for checkboxes, they can be the same.&lt;/li&gt;
&lt;li&gt;The id and name can have the same value, but each id should be unique with other ids, same for the name attribute.&lt;/li&gt;
&lt;li&gt;There is an attribute called "checked", that you can specify if to have a checkbox checked by default.
Here is another example with two checkboxes:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"topping"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"cheese"&lt;/span&gt; &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"cheese"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Cheese&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"topping"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"mushrooms"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"mushrooms"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Mushrooms&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"topping"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"olives"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"olives"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Olives&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you noticed, I have the same name, since later since they are about toppings, I can get the values programatically in a list by using that name, so all my toppings selected would be extracted at once. But the ids are different.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2yh4cbwpr8i4p7aphvdh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2yh4cbwpr8i4p7aphvdh.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Radio buttons
&lt;/h4&gt;

&lt;p&gt;Radio buttons are useful when you want your user to select &lt;strong&gt;only one&lt;/strong&gt; option. Here too, the name for each radio button is the same but the ids are different. And you can also have the checked attribute to have one checked by default. To create a radio button, you specify the value "radio" in the type attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"gender"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"male"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"male"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Male&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"gender"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"female"&lt;/span&gt; &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"female"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Female&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"radio"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"gender"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"other"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"other"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Other&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4oipjlomnis0krsuhs7q.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4oipjlomnis0krsuhs7q.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that if you have other radio buttons with another name, it won't be a problem, the "only one" concerns radio buttons with the same name.&lt;/p&gt;

&lt;h4&gt;
  
  
  Other input types
&lt;/h4&gt;

&lt;p&gt;The list of types that exist is so long so I don't want to kill you with new information, the ones I showed you are the most used inputs but if you are curious about other types here is a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input" rel="noopener noreferrer"&gt;list&lt;/a&gt;, hope it will help you! Also, you don't need to push yourself to remember them immediately, it will come with time and practice, the more you use them, the more you'll remember them, worst case Google is your friend!&lt;/p&gt;

&lt;h4&gt;
  
  
  Submitting your form
&lt;/h4&gt;

&lt;p&gt;Now that you have a bunch of input elements you can use inside your form it's time to show you how you can submit your data and send it to the server. There is an specific type of input called "submit" that allows us to exactly do that. By default the word is "Submit" but if you want to change it, you can do it by entering the word you want to display with the attribute value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Send"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 The button element
&lt;/h3&gt;

&lt;p&gt;While the input of type &lt;code&gt;submit&lt;/code&gt; is always found inside forms, buttons can be found anywhere in an HTML document. In our case, we're only interested in using it inside the form to send our data. To do that, we add to the button the type attribute with the value of submit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main advantage of having a submit with a button instead of input is that you can create a more complex component, it can have an icon, and more if you want, while the input can have only the text it has in the value attribute.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 Textarea element
&lt;/h3&gt;

&lt;p&gt;We saw earlier that &lt;code&gt;&amp;lt;input type="text"&amp;gt;&lt;/code&gt; allows us to enter a single line text. Now we want to be able to enter a real text with multiple lines. The &lt;code&gt;&amp;lt;textarea&amp;gt;&amp;lt;textarea&amp;gt;&lt;/code&gt; element comes with an opening tag and a closing tag, you can specify in advance the text by putting it in between, or leave it like that for the user to enter their content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"comment"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Comment&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"comment"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"comment"&lt;/span&gt; &lt;span class="na"&gt;rows=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="na"&gt;cols=&lt;/span&gt;&lt;span class="s"&gt;"30"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The size of this textarea is determined by the number of rows and columns it can have (a bit weird for the columns but, it is what it is). Here are some useful attributes you can use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;maxlength: the maximum number of characters allowed.&lt;/li&gt;
&lt;li&gt;placeholder: so tat you can describe the expected content.&lt;/li&gt;
&lt;li&gt;required: if you want to ensure that it won't be left empty.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2.4 Menu options
&lt;/h3&gt;

&lt;p&gt;Many pages have some sorts of menus where you select one of the options. Let's say you're registering into a website and they ask you to specify your country among a list of countries. This is done by using the &lt;code&gt;&amp;lt;select&amp;gt;&amp;lt;/select&amp;gt;&lt;/code&gt; element, associated with a list of &lt;code&gt;&amp;lt;option&amp;gt;&amp;lt;/option&amp;gt;&lt;/code&gt; elements inside.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"countries"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Choose a country:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;select&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"countries"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"countries"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Country&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"frontend"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Front-end Land&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"backend"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Back-end Land&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"fullstack"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Full Stack Land&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/select&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here I have my label, for and id have the same values to associate the label and the select element. And inside I have a list of options. The text in between is so that it will be displayed on the page, and the value attribute holds the data that will be sent to the server. So when a user clicks on an option, it's the value that will be sent not the text in between.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff82aozr90s0irnl2mfpt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff82aozr90s0irnl2mfpt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Now here is a cool trick, what if you want a user to choose their nationality, but they have two? With select, we can create multiple groups of options, and in each group you can pick an option. For that we need another element: &lt;code&gt;&amp;lt;optgroup&amp;gt;&amp;lt;/optgroup&amp;gt;&lt;/code&gt; and the optgroup has the attribute "label" that can be used ti describe each group! Inside each &lt;code&gt;&amp;lt;optgroup&amp;gt;&lt;/code&gt; you would have your options.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx1bp0mhxmnjekllhw9fu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx1bp0mhxmnjekllhw9fu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"nationalities"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Choose a car:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;select&lt;/span&gt;  &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"nationalities"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"nationalities"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;optgroup&lt;/span&gt; &lt;span class="na"&gt;label=&lt;/span&gt;&lt;span class="s"&gt;"First nationality"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"dreamer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Dreamer&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"worker"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Worker&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/optgroup&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;optgroup&lt;/span&gt; &lt;span class="na"&gt;label=&lt;/span&gt;&lt;span class="s"&gt;"Second nationality"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"morning person"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Morning person&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"night person"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Night person&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/optgroup&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/select&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3y6mg5grnaq0o8d3gix5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3y6mg5grnaq0o8d3gix5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Wrap up
&lt;/h1&gt;

&lt;p&gt;With all that, let's create a form for registration:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/bGBpJRq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And here is a small summary about all what you've learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML forms allow us to have a better user experience on our websites.&lt;/li&gt;
&lt;li&gt;All HTML forms have a &lt;code&gt;&amp;lt;form&amp;gt;&amp;lt;/form&amp;gt;&lt;/code&gt; element as a parent.&lt;/li&gt;
&lt;li&gt;Our elements are nested inside the &lt;code&gt;&amp;lt;form&amp;gt;&amp;lt;/form&amp;gt;&lt;/code&gt; element.&lt;/li&gt;
&lt;li&gt;There are multiple elements that can be used: inputs (for email, username, date, numbers...etc), buttons (to send our data), textarea (to enter a text), select (to create menus).&lt;/li&gt;
&lt;li&gt;You can select multiple checkboxes while you can select only one radio button in a form as long as the radio elements have the same name.&lt;/li&gt;
&lt;li&gt;We can have more complex menus using &lt;code&gt;&amp;lt;optgroup&amp;gt;&amp;lt;/optgroup&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Thank you
&lt;/h1&gt;

&lt;p&gt;Once again I am so happy that you've read up to this point! If you have a dream, don’t just sit there. Gather courage to believe that&lt;br&gt;
you can succeed and leave no stone unturned to make it a reality. All your efforts are worth it, looking forward to see how you will shine in the future! If you liked this post please like and share, and if you have any question feel free to ask and I will gladly answer! See you soon!&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>All you need to know about HTML tables</title>
      <dc:creator>Hildweig 🐬</dc:creator>
      <pubDate>Sun, 24 Jan 2021 17:33:49 +0000</pubDate>
      <link>https://forem.com/hiidweig/all-you-need-to-know-about-html-tables-m8f</link>
      <guid>https://forem.com/hiidweig/all-you-need-to-know-about-html-tables-m8f</guid>
      <description>&lt;p&gt;This week's subject is HTML tables, this post is a part of my HTML beginner series. If you haven't checked the previous ones I highly recommend you to read them! If you already know the basics and just one to know about HTML tables you can skip them and read this one directly instead. This course is structured in a way that will make you grasp the information more clearly. You will learn how to create basic HTML tables, their components, how to have those tables that have cells expanding on more than one cell, when to use tables, and more! Let's get started!&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Tables?
&lt;/h1&gt;

&lt;p&gt;One of the most efficient ways to present a large amount of information to a reader is to collect them in a table, tables can supplement the text and also make it easier for you to explain something hard to explain with plain text. Tables are also the best when you want to have spreadsheet-like content. In HTML, you can create tables easily.&lt;/p&gt;

&lt;h1&gt;
  
  
  Create your first table
&lt;/h1&gt;

&lt;p&gt;Let's go back to the basics, a table should have rows, columns, and the intersection between them create cells, and sometimes, you may find a caption attached to a table (like in Microsoft word). We'll first try to create our table using this definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In HTML, a table is defined using the &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; element, it has an opening tag and a closing tag, and you put the content in between.&lt;/li&gt;
&lt;li&gt;Rows are defined using the &lt;code&gt;&amp;lt;tr&amp;gt;&amp;lt;/tr&amp;gt;&lt;/code&gt; element (table row), so if you want a table with three rows it would look like something like this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;For columns, there is no such thing as  if you tried to guess the next element, instead, you have full control over the number of columns you want to have in each row (but I advise you to have the same number otherwise it would look weird and has no sense). The columns are indirectly defined using the table data element &lt;code&gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;/code&gt; , it has also an opening tag and a closing tag, and your actual data is in between, simple as that.
So let's see how our table is structured so far:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Saturday&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Sunday&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Monday&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
  &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Vegetables Soup&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Jardiniere&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Fish &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; Potato&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
 &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$10&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$12&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$16&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check here the result, I styled it a bit so that you can see clearly the elements:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/eYdwmeK?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now that I'm looking at it, I kinda want to make a distinction between the days of the week and my meals. And I also want at the end to have a row where there is the average cost of my meals, and there is a way to do that! In fact, what we've done earlier wasn't a "well created" table. HTML let us define three components in our table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A header&lt;/strong&gt; : you want to use it to contain the name of your columns in the header. Having a header inside your table makes it easier to find the data you're looking for if the header elements stand out from the other ones. Of course, there are other ways you might say (using CSS) but if you appreciate content that is highly semantically and you like doing things how they should be, I really recommend you to include it. So there, we will contain the days of the week in the header. The HTML element for the table header is &lt;code&gt;&amp;lt;thead&amp;gt;&amp;lt;/thead&amp;gt;&lt;/code&gt;, and the content of your header is wrapper inside a header cell &lt;code&gt;&amp;lt;th&amp;gt;&amp;lt;/th&amp;gt;&lt;/code&gt;, the text looks bold and is centered by default. You can check here the code and how it looks:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/JjRQoeQ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And notice that we still have a row, we just added the thead element and replaced the tr with th!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now for the &lt;strong&gt;data&lt;/strong&gt; : you should wrap your table rows inside a &lt;code&gt;&amp;lt;tbody&amp;gt;&amp;lt;/tbody&amp;gt;&lt;/code&gt; element (table body). The header element should always come before this element. Okay, so let's apply this to our table:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/jOMjPpJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Our third step is to add a &lt;strong&gt;footer&lt;/strong&gt; : you don't always need to have a footer in your table, but if you need one then you can use the &lt;code&gt;&amp;lt;tfoot&amp;gt;&amp;lt;/tfoot&amp;gt;&lt;/code&gt; element (table footer). Both the thead and tfoot elements contain ancillary information to support the main information of the tbody. Plus, even if it seems logical to have it at the end, it's not a general rule, sometimes you may find a header then footer then the body, and sometimes the header then body then the footer. I will show you soon an example with a footer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Add a little touch to your table
&lt;/h2&gt;

&lt;p&gt;Now that we know how to create a basic table I want to show you some more of what you can do on tables.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Captions
&lt;/h3&gt;

&lt;p&gt;Suppose I'm one of your users and I'm reading a content in your page, and then there is a table. Having a caption in your table will help me to understand what that table represents, and it will make things easier for me to decide if I want to read it or skip it. Captions also help people who use screen readers since most screen readers announce the content of captions. It should always come first (even before the thead element).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;caption&amp;gt;&lt;/span&gt;
    My holidays meal plan and cost.
  &lt;span class="nt"&gt;&amp;lt;/caption&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Saturday&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Sunday&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Monday&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
  &lt;span class="nt"&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Vegetables Soup&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Jardiniere&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Fish &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; Potato&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$10&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$12&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$16&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you try this snippet, you'll see that the caption is centered by default. You can also add more details to the caption and nest elements inside if you want to style them differently later on. (It's okay if you don't know styling yet, just know that you can have a sort of title followed by a text if you want in your caption, and even more but it would be weird if you had something else I think).&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/QWKXjBj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Cells? Fuuuusion!
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZBCuLBpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dthpn21cg6qa228lfiat.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZBCuLBpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dthpn21cg6qa228lfiat.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you know that your cells can become super saiyan? By merging two or more cells your cell can take vertically or horizantally the space of the number of cells you want. To understand how this work we need to understand two attributes that can go on any cell element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. rowspan: by default, your cell has indirectly a rowspan= "1", if you want it to span more vertically, then you can add it to the cell you want, say 2 for example : rowspan= "2" will have the space of 2 rows.&lt;/li&gt;
&lt;li&gt;2. colspan: here too, by default your cell has indirectly a colspan= "1", if you want to have more than that, add the attribute with the number you want. Of course, you can have rowspan and colspan included in the same cell.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, I want my table to have a footer for the sum of all meals, and since it's a sum, I will span the cell horizontally for the three meals.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/zYKVrGW?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  3.Create groups for columns
&lt;/h2&gt;

&lt;p&gt;We said earlier that the columns are implicitly represented with the &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; elements. This is true, but imagine later on if you want to apply different styles for each group of columns, let's say we have a table for a student semester grades, the first column is for subjects names, the following columns for the grades, and the last one for teachers remarks. The first and last columns I want them with a style, and the ones in between with a different style. (this is just an example) HTML lets us group our columns using the &lt;code&gt;&amp;lt;colgroup&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;col&amp;gt;&lt;/code&gt; elements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. &lt;strong&gt;colgroup&lt;/strong&gt;: The &lt;code&gt;&amp;lt;colgroup&amp;gt;&lt;/code&gt; element should be child of the &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt; element, you have to put it after the &lt;code&gt;&amp;lt;caption&amp;gt;&lt;/code&gt; element if there is one, and before any &lt;code&gt;&amp;lt;thead&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;tbody&amp;gt;&lt;/code&gt;, or &lt;code&gt;&amp;lt;tfoot&amp;gt;&lt;/code&gt; elements.
&lt;li&gt;2. &lt;strong&gt;col&lt;/strong&gt;: Now to define your columns groups, use the &lt;code&gt;&amp;lt;col&amp;gt;&lt;/code&gt; element within the &lt;code&gt;&amp;lt;colgroup&amp;gt;&lt;/code&gt; element. You also need to add an attribute in this element which specifies how many columns your group &lt;strong&gt;spans&lt;/strong&gt;, for example, if my group has three columns I would write &lt;code&gt;&amp;lt;col span="3"&amp;gt;&lt;/code&gt; (this element comes with just one tag)

&lt;/li&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;colgroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;col&lt;/span&gt; &lt;span class="na"&gt;span=&lt;/span&gt;&lt;span class="s"&gt;"3"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/colgroup&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;caption&amp;gt;&lt;/span&gt;
    My holidays meal plan and cost &lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;The first row represents the days, the second one the meals, and the third one the cost of each meal&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/caption&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Saturday&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Sunday&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Monday&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
  &lt;span class="nt"&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Vegetables Soup&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Jardiniere&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Fish &lt;span class="err"&gt;&amp;amp;&lt;/span&gt; Potato&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt; 
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$10&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$12&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;$16&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;br&gt;&lt;br&gt;
You will find them more useful once you learn CSS don't worry.&lt;/p&gt;
&lt;h2&gt;
  
  
  Some advices
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1- Do not use HTML tables for layouts
&lt;/h3&gt;

&lt;p&gt;HTML tables should be only used for their real purpose which is to organise your data in a table form. Some people use it for layouts too (a row for header, one for the content, etc), and you really &lt;strong&gt;should not&lt;/strong&gt; use it this way, here are some reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. Screen readers used by blind people are tools that interpret the tags that exist in HTML and read the content to users. Because tables are not appropriate for layouts usage the screen readers won't read it in un "understandable" way. Imagine if someone would read to you a text backwards, or a word each line then go back to the first line, weird right? Well, you can imagine how confusing screen readers would read the content if you layout your page using tables.&lt;/li&gt;
&lt;li&gt;2. Difficult to maintain: making modifications on such a page with all the rows and cells would bring you more pain than you could imagine.&lt;/li&gt;
&lt;li&gt;3. Tables aren't responsive by default. They are sized according to what they contain, while the normal layout containers (header, section, article, div) have their width set to 100% of their parent element. Using tables would make you do extra work to make it responsive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2- Can you have nested tables?
&lt;/h3&gt;

&lt;p&gt;The answer is yes, it is doable. However you should avoid that practice as much as possible. You will have the same issue with screen readers (weird reading), so you can add extra columns and cells instead.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;That's it for today! If you read up to this point I'm so proud of you and you should be proud of yourself as well. No one can take away the hardwork you're putting and the results you'll get if you persevere. Don't forget to enjoy your journey and share your progress with the community to keep yourself motivated and motivate others with you!&lt;br&gt;
If you liked this post, please share it and feel free to share your thoughts in the comments. If you have any suggestions about what you want to learn you can tell me in the comments as well.&lt;br&gt;
Here is a summary of what you learned today:&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KbRM0cQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/es5pk5mhlkxr4t66f0sd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KbRM0cQn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/es5pk5mhlkxr4t66f0sd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Thank you for reading and see you soon!&lt;/p&gt;


&lt;/table&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>html</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>HTML tags for SEO success</title>
      <dc:creator>Hildweig 🐬</dc:creator>
      <pubDate>Sun, 17 Jan 2021 22:21:45 +0000</pubDate>
      <link>https://forem.com/hiidweig/html-tags-for-seo-success-l1j</link>
      <guid>https://forem.com/hiidweig/html-tags-for-seo-success-l1j</guid>
      <description>&lt;p&gt;So you created a website and you're wondering why you don't have that many visitors? You tried to promote your page using Facebook or Instagram, and even you paid a great amount of money to reach a certain number of visitors? Let me ask you two other questions:&lt;br&gt;
Did you know that organic ranking generates more traffic than paid search? And did you know that there are some free ways to get more visitors? Well, this is precisely what I am going to talk about in this post. If you're interested keep reading, hopefully, you'll find some good tips you didn't have knowledge of. Without further ado, let's start!&lt;/p&gt;
&lt;h1&gt;
  
  
  Introducing HTML tags for SEO
&lt;/h1&gt;

&lt;p&gt;To be on the same page, what are HTML tags? (You might want to check my previous post &lt;a href="https://dev.to/hiidweig/html-basics-starts-from-zero-59a2"&gt;here&lt;/a&gt;) HTML tags are snippets of HTML coding that provide the directions for the visual content that we see on the Web, they also tell engines how to "read" your content. In fact, they have a great influence on ranking pages. They can provide a better navigation (more traffic), help query matching, guide search engines on where to find relevant informations. In addition, they let you personalize how social media show your articles. In the end, it’s HTML tags for SEO that determine how likely you are going to have a decent rank.&lt;br&gt;
Since I want this post to be beginner friendly, I choosed the mostly used ones, so you can include them in your pages:&lt;/p&gt;
&lt;h2&gt;
  
  
  Header tags
&lt;/h2&gt;

&lt;p&gt;These are the tags that you can include in your header element.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Title tag
&lt;/h3&gt;

&lt;p&gt;The title tag basically describes what your content is about.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;My fancy title&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqnb1xlbn2133gjx1bbb5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqnb1xlbn2133gjx1bbb5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The first thing that you see in search engine result pages is indeed the title tag, if your title doesn't pick the interest of users, they are less likely to click on the link. Besides, the title tag is displayed on your browser tab, so if you have many tabs open, the title makes it easier to retrieve the tab the user wants. Finaly, the title is also shown when someone shares your link in social media.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some advice on the title tag&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not stuff your title with keywords because it might be changed by Google to a title that seems more relevant to the content. So make sure that the title faithfully describes the content.&lt;/li&gt;
&lt;li&gt;Keep the length under 70 characters, if your title is long, keep in mind how much space the characters occupy so that it won't be cut (you can use &amp;amp; instead of and, "/" instead of or, etc.)&lt;/li&gt;
&lt;li&gt;Your keywords should be at the beginning of the title so that they are easily spotted.&lt;/li&gt;
&lt;li&gt;Do not repeat the same titles accross your website, Google may penalize your website thinking it has duplicate content.&lt;/li&gt;
&lt;li&gt;If you are a known brand, you can use the brand name at the end of your title, it will add more value to your title while focusing on the title itself, unless it's a home / about / contact us page.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  2. Meta description tag
&lt;/h3&gt;

&lt;p&gt;Having a catchy description can help to push users to click on your results in the search engine result pages (SERPs). In HTML it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Some catchy description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here is how the description is shown in the SERP:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fghlky1evldsvsx8rq4t6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fghlky1evldsvsx8rq4t6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that sometimes, Google might quote a copy of your page if by doing so it better suits the query rather than your description. Although this tag is not a ranking factor, I'm sure that most of you instinctively look at the description before clicking, and they also appear across social media when users share your URL!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some advice on the meta description tag&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What I can advise you is that you should write a description that matches best the content of your page while avoiding duplicate descriptions.&lt;/li&gt;
&lt;li&gt;Also, avoid alphanumeric characters, when you use quotation marks, for example, Google will ignore the sentence in between, so it is safer to not use any alphanumeric characters at all.&lt;/li&gt;
&lt;li&gt;Once again, keep the length in mind, since only the first 150-160 characters will be kept, and the rest is cut; and make sure to include what's most relevant at the beginning.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Open graph tags
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://ogp.me/" rel="noopener noreferrer"&gt;Open graph tags&lt;/a&gt; are part of Facebook open graph protocol, you can find them in the head section of a web page, and the reason that they were created is that they enable you to control how information about your page is represented in social media, meaning that they influence the performance of your links in social media. All of major platforms recognize them and are widely used (Google, LinkedIn, Twitter, etc.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg0s41ai2961t79rkor2g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg0s41ai2961t79rkor2g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Twitter cards
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started" rel="noopener noreferrer"&gt;Twitter cards&lt;/a&gt; are very similar to open graph tags; in fact, open graph tags are used in Twitter if no Twitter card is present. They are exclusively used by Twitter.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Robot tags
&lt;/h3&gt;

&lt;p&gt;Robot tags are snippets of code that tell search engines what pages you want to index, and which ones you don't. So that individual pages can be ignored. It might help you to avoid some problems if you think that some pages should not be indexed but you still want to keep them. If this tag is not included, search engines would index all of your pages by default. Here is how it looks in HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"robots"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"index, follow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can specify the following parameters in your robot tags:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;noindex&lt;/strong&gt;: prevents from indexing a page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;nofollow&lt;/strong&gt;: prevents the search engine from following the globality of the links on a page. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;noarchive&lt;/strong&gt;: prevents a cached copy of a page to appear in the search result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;nosnippet&lt;/strong&gt;: prevents the description of a page from appearing in the search result, as well as caching the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;none&lt;/strong&gt;: used for "noindex, nofollow".&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Canonical tags for prioritization
&lt;/h3&gt;

&lt;p&gt;If you have pages with identical content, you can choose which one should have more priority using this tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://www.facebook.com/HildweigDev"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"canonical"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be an amazing trick to counter the problem we talked about above for duplicate content!&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Responsive website
&lt;/h3&gt;

&lt;p&gt;A responsive website is a website that is shown in a friendly way for desktop and mobile screens. Google prioritizes websites that are responsive over unresponsive ones. But how does it know that it is responsive ? Simply by looking at this snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those were the tags that you can include inside your head element. Now let me show you some useful tags that you include inside the body element!&lt;/p&gt;

&lt;h2&gt;
  
  
  Body Tags
&lt;/h2&gt;

&lt;p&gt;These are the tags that you can include in your body element&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Header tags for the win!
&lt;/h3&gt;

&lt;p&gt;How many of you scan the page content by scrolling through the titles before reading the actual content? That's one use. In terms of SEO, using headers means that you're telling the search engines more efficiently what exactly your content is about. Google also uses headers to create some list-like snippets when looking for a particular topic:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fov7nhv6es9767qezbuuq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fov7nhv6es9767qezbuuq.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Some advice about the headers&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's a good practice to have one h1 header per page, you can use h2 for lower value titles, then h3 if necessary, and so on. Use the headers smartly to make the content of each section clear.&lt;/li&gt;
&lt;li&gt;It's also a good practice to include your keywords or their synonyms in your headers, but try to not stuff them okay?&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  2. Alt attribute on images
&lt;/h3&gt;

&lt;p&gt;Alt attributes are part of the image tag, not do only they provide an alternative text for the image if it is not shown correctly, but it is also useful for search engines so that they know what that image represents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"url"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A clear description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Some advice on the alt tag&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is unnecessary to optimize each image description, focus only on those that add value to your content, some useful information.&lt;/li&gt;
&lt;li&gt;Again, you can benefit from using them if you include keywords (without overuse).&lt;/li&gt;
&lt;li&gt;Make the description clear and concise.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Good usage of links
&lt;/h3&gt;

&lt;p&gt;A good practice is to link your page to other pages that are inside your website to enhance the website traffic. This is called internal linking, external linking on the other hand are links that point to a page of another website. Links also help search engines to find and index the pages of your website. This is quote from Google:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Some pages are known because Google has already crawled them before. Other pages are discovered when Google follows a link from a known page to a new page.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Another thing is that, if you want to use external links and make search engines ignore the connection, or when you link to a website with a poor domain authority, use the "nofollow" attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://www.facebook.com/HildweigDev"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"nofollow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Maybe you want to follow my page?&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;That's it for today. Congratulations for reading the entire post! Most of the things in life are not within our control, but this time, these efforts, your dedication are within your control. If you liked the content please let me know! Also if you have other tips that you would like to share feel free to share them in the comments!&lt;br&gt;
Here is a summary of the tags that we discussed today:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ferrey5fm7oz34dlbyfoz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ferrey5fm7oz34dlbyfoz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
See you soon!&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>HTML Basics: Start from zero!</title>
      <dc:creator>Hildweig 🐬</dc:creator>
      <pubDate>Sun, 10 Jan 2021 19:49:56 +0000</pubDate>
      <link>https://forem.com/hiidweig/html-basics-starts-from-zero-59a2</link>
      <guid>https://forem.com/hiidweig/html-basics-starts-from-zero-59a2</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;When I started learning HTML, that was back then at the university. For some reason we spent the entire semester only talking about it, and even with all that time, it was still hard for me to remember the information, and the way we were taught just made me think that maybe web development wasn't for me. Now I'm glad that I still did give it a serious shot and didn't listen to my dark thoughts. My goal today is to give you some basics of html. This is my first post for a long journey, I will try to teach you what I know in the most simplest way. There are absolutely no pre-requisite required, I will try to explain things in a way that anyone can understand!&lt;/p&gt;

&lt;h1&gt;
  
  
  Why learn HTML? &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;HTML stands for "HyperText Markup Language", it is not a programming language but a markup one instead, in programming there is logic, there are operations, in HTML you don't have these. An important question you want to ask yourself before to start learning something is: "why should I learn it?", you also want to make sure that it matches your goals and priorities. Now, if you would like to become a web developer, you need to know that HTML is the skeleton of any web page; having a solid grasp of its core concepts will not only help you to become a web developer, but it will also distinguish you from the less good ones who write it arbitrarily.&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic structure of HTML
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Document Title&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    Your content here
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any HTML file would necessarly have this structure, and each element here has an important role:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The DOCTYPE: I think that just its name gives us a hint about what it does (another hint: document type). This element tells to the browser that it is looking at the document of the specified type, in this case, the document type is html. Always put it at the top of your html file&lt;/li&gt;
&lt;li&gt;The html element: your real HTML code starts there. That's the root of your document, and I'm intentionally using the word root because, if you noticed, the structure looks exactly as a family tree, you have the ancestors, the one that has everything wrapped inside of it, and then parents and children,... And each family member has also its own family, just like us! Almost all html elements have an opening tag and a closing tag, and between them is the content of that element. You can also picture it as the russian dolls called Matryoshka, the only difference is that each doll in our html can have many other dolls at the same level, as much as we need!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7otm5dymmnt5g1roug7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7otm5dymmnt5g1roug7s.png" alt="Alt Basic Structure of HTML"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The head element: the html head element is where you put your meta data which are information concerning your page, for example the author, the description of the content, etc. For your SEO strategy, knowing what to include in the head element is crucial so that your page will be more visible. For now let's not over complicate it and just keep in mind that anything that is inside the head element won't be displayed in your page, but still will be used for different purposes.&lt;/li&gt;
&lt;li&gt;The charset meta tag: here you are setting the character encoding, there are different encodings (ASCII, ISO, utf-8, ...), but I've never seen so far another character encoding used other than utf-8 in web pages, still you can use whatever suits you!&lt;/li&gt;
&lt;li&gt;The viewport meta tag: you should include the viewport meta tag in all your html files, it allows the browser to control the page dimension and the way it scales. The initial-scale=1.0 means that the zoom level is set to one, and the width=device-width means that the width of the page is equal to the width of the user's screen. If you don't use it the page won't be displayed correctly.&lt;/li&gt;
&lt;li&gt;The title element: we use it to display the name of your page, simple as that! The titles you see on your tab are embedded inside that element.&lt;/li&gt;
&lt;li&gt;The body element: This is were you are going to put all the content that will be displayed in your page!&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Some HTML elements
&lt;/h1&gt;

&lt;p&gt;With that basic structure discussed above, the only thing you'll have is an empty page with a title in your tab, and chances are that you are more interessted in knowing how to make a real page with content in it. Anything you see in your page is inside the body element. But your content need to be formatted, it needs to have a structure, you don't want to throw your text or whatever directly okay? The first reason is that it's the only way for the browser to know the type of content you have, if it's a title, or a paragraph or an image... The second reason is that if you structure it nicely you'll have less trouble to style it, to add specific background to a part of your content, or something like that. Thankfully html has it all! That way your content will be both human and machine readable!&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of HTML elements
&lt;/h2&gt;

&lt;p&gt;We have just two types: standards elements, and empty elements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A standard element is an element that has an opening tag, a closing tag, and content in between. A standard element can also have many elements inside and in this case we will have what we call a nested element.&lt;/li&gt;
&lt;li&gt;An empty element has only a tag and the content is a value of an attribute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today I will show you elements that you can use as "containers", and elements that wrap your text, images, titles, etc!&lt;/p&gt;

&lt;h3&gt;
  
  
  The big containers
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The header
&lt;/h4&gt;

&lt;p&gt;Let's say that at the top of your page you have a menu and a logo, these are generally contained inside a header!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;header&amp;gt;&lt;/span&gt;Something&lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  nav
&lt;/h4&gt;

&lt;p&gt;You use it to wrap your navigation, and it is generally inside your header element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;Your navigation here&lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  section
&lt;/h4&gt;

&lt;p&gt;You'll have for example a section for the introduction, one for the main content, a section for the contact information, you name it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;Content of the section&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  article
&lt;/h4&gt;

&lt;p&gt;You want to include a magazine or a newspaper article? Simply use the article tag! Another cool thing is that if you have a list of articles, each one will be contained separately! Besides, you can find sections that have articles and vice versa.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;article&amp;gt;&lt;/span&gt;My article&lt;span class="nt"&gt;&amp;lt;/article&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  aside
&lt;/h4&gt;

&lt;p&gt;If you have some information that is indirectly related to your main information you can use the aside tag to do that. In my copybook I put some aside information in the margin, the aside tag can be used in the same way!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;aside&amp;gt;&lt;/span&gt;My side information&lt;span class="nt"&gt;&amp;lt;/aside&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  footer
&lt;/h4&gt;

&lt;p&gt;Most of web pages have a footer at the end where they put their copy right, some article links, etc. Use the footer tag to create a footer (oki)!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;&lt;span class="ni"&gt;&amp;amp;copy;&lt;/span&gt; Hildweig, 2021&lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Headings, paragraphs, lists, links, and images
&lt;/h3&gt;

&lt;p&gt;To not make this post too long, I will just give you a general idea about what you can find inside of the previous containers.&lt;br&gt;
You'll have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Titles: in HTML there are six tags just for headings so that we can semantically represent the importance and level of each of our headings. THe most important heading in your section will be h1 (heading 1), if you have a subtitle use h2, and so on. In your browser their size is also different, h1 is displayed very big, h2 less bigger, and the smallest is h6, but please avoid using a heading just for its size, instead you can resize them using css which is specially created for styling HTML elements, and avoid skipping heading levels, start with h1, then h2, and so on ^^.
&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/xxEaVaG?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/li&gt;
&lt;li&gt;Paragraphs: Use the &lt;p&gt; tag to display your paragraphs!
&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;The journey of a thousand miles begins with one step.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Lists: In HTML, there are two types of lists: ordered lists, and unordered ones. A common use case for the unordered list is to be the container of your navigation elements, something like that:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Home&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;About Us&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Contact Us&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both types of lists have li tags that refer to the element itself. Now say I want to display a recipe, or the top movies of 2020? Ordered lists are best for this task. And the only difference is that instead of using ul (for unordered list) we use ol (ordered list) and it has numbers.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/ZEpMOYz?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Links: What kind of page doesn't have links? To display links you use the a tag, but why a and not l for link? Well, here they use the a for "anchor". Here is the simplest way to add a url to your page:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://www.facebook.com/HildweigDev/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;More here&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have your a starting tag, then a key value pair thingie, this is what we call an attribute; attributes provide additional information to your element and come as key value pairs, the href here means hyperlink , and its value is your url, what will be shown in your page is text in between, and clicking on it will send you to the page!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lastly, you want to have some beautiful images otherwise it's boring... For that you can use the img empty element. Okay finaly an empty element ^^'. So as I said before, empty elements have only one tag and the content is actually a value of an attribute.
Check the html here:
&lt;iframe height="600" src="https://codepen.io/Hildweig/embed/ExgeyWg?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;

The src stands for "source", so there you'll add the link or path to your image. The alt attribute is optional, however I strongly think that you should add it. In case there is an issue and the image doesn't show up, the alt value (the text) will be displayed instead of the image. In addition, the alt provides a better context to search engine crawlers, helping them to index an image properly. I don't want to you to be lazy, so make sure to include it okay?&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Thank you
&lt;/h1&gt;

&lt;p&gt;If you read this post to the end, I want you to pat yourself on the back and be proud of your discipline. Becoming a web developer requires patience, discipline and curiosity. Big goals are achieved with small daily achievements. If you liked it please like and share your thoughts with me so that I can provide better educative content.&lt;/p&gt;

</description>
      <category>html</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
