<?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: Danilo César</title>
    <description>The latest articles on Forem by Danilo César (@danilo).</description>
    <link>https://forem.com/danilo</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%2F616236%2Ff625e44c-bd58-4b90-a6e6-5c6a932f7595.jpg</url>
      <title>Forem: Danilo César</title>
      <link>https://forem.com/danilo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/danilo"/>
    <language>en</language>
    <item>
      <title>Tired of Cookies? Here's the reason why</title>
      <dc:creator>Danilo César</dc:creator>
      <pubDate>Sun, 15 May 2022 02:41:39 +0000</pubDate>
      <link>https://forem.com/danilo/tired-of-cookies-heres-the-reason-why-22od</link>
      <guid>https://forem.com/danilo/tired-of-cookies-heres-the-reason-why-22od</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;tl;dr:&lt;/strong&gt; This post is an brief analysis about the issue of having so many "opt-in" banners about cookie consent policies, using mainly the GDPR as legal basis to this subject. Cookies are necessary to the technical proceedings and operations on many web servers, but it doesn't mean we don't get tired of ticking so many checkboxes online.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;You probably noticed that in the last few years most of sites are welcoming newcomers users with some kind of a banner, or a pop-up window, with a friendly message asking you to accept some cookies in order to access and enjoy the content of their pages.&lt;/p&gt;

&lt;p&gt;There is a reason for it, and if you are the owner of some webpage that collects some user data, even if you are not sending it to third-party companies that generates analytics or user's behaviors reports, you should probably start doing it too. I know, it's frustrating, but it's necessary. Let's find out why.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compliance and Accountability
&lt;/h2&gt;

&lt;p&gt;The first thing we need to know about, in order to understand what those &lt;em&gt;cookies&lt;/em&gt; mean, and why the companies are so worried about asking users to consent to this action, is due to &lt;em&gt;compliance.&lt;/em&gt; In matter of legal aspects, it describes the needs to conform to the rules imposed to that subject or that proper area, and that also includes the law, standards and regulations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lon6xVH_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcryrtfcldjap27r6tu1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lon6xVH_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcryrtfcldjap27r6tu1.jpg" alt="Compliance and Accountability" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@hpzworkz?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Hassan Pasha&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In matter of webpages, for instance, located in the European Union (EU), in the European Economic Area (EEA) or in the United Kingdom (whose state version, the UK-GDPR, is almost identical to the EU-GDPR), those owners of those pages must inform and obtain the authorization from the users whose data are being processed, whether for purposes of performance analysis, user experience metrics (UX) or even to target more relevant ads to the audience of their sites. This is what predicts the &lt;em&gt;General Data Protection Regulation&lt;/em&gt;, or GDPR, one of the legal diplomas that disposes about privacy and personal data protection for people inside and outside those States.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 If you do not reside in the aforementioned countries, but does any operation involving processing of personal data from people or companies located in the countries where the GDPR rules applies, &lt;a href="https://gdpr.eu/companies-outside-of-europe/"&gt;this law is also mandatory&lt;/a&gt;. This is what the &lt;em&gt;Article 3(1)&lt;/em&gt; of GDPR disposes: "This Regulation applies to the processing of personal data in the context of the activities of an establishment of a controller or a processor in the Union, regardless of whether the processing takes place in the Union or not".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In fact, even if the website transfers these information to third-parties (who will process this data), those responsible for collect, organize and, finally, the &lt;em&gt;processing&lt;/em&gt; of this personal data must ensure they do so within one of the disposed lawful basis.&lt;/p&gt;

&lt;p&gt;And what are those lawful basis? The &lt;a href="https://ico.org.uk/for-organisations/guide-to-data-protection/guide-to-the-general-data-protection-regulation-gdpr/lawful-basis-for-processing/"&gt;UK-GDPR predicts&lt;/a&gt; at least six of them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By consent;&lt;/li&gt;
&lt;li&gt;By contract;&lt;/li&gt;
&lt;li&gt;By legal obligation;&lt;/li&gt;
&lt;li&gt;For vital interests;&lt;/li&gt;
&lt;li&gt;For public interest or legal authority;&lt;/li&gt;
&lt;li&gt;For legitimate interests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the purposes of this article, we will solely focus on the first two of them: by consent; and by contract.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--02SPOd1u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8y2aduvm5uuseojcxzx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--02SPOd1u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8y2aduvm5uuseojcxzx.png" alt="Google 27 EU Locations Add Cookie Law Notice" width="640" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Image: &lt;a href="https://www.seroundtable.com/google-cookie-eu-notice-16614.html"&gt;Google 27 EU Locations Add Cookie Law Notice&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Lawful basis of GDPR
&lt;/h3&gt;

&lt;p&gt;The lawful basis of contracts is usually associated with an agreement set by the parties, such as an employment contract or an obligation contracted by a company to store the personal data sent by the other party in order to process it, for example, to generate analytical reports used for decision-making.&lt;/p&gt;

&lt;p&gt;Notice that when the law says &lt;em&gt;personal data&lt;/em&gt; it does not mean just the full name, address, or telephone number of these data subjects. In fact, personal data means any information that can really identify that person. So, even if we are working with two different databases, where one of them contains the full name of a natural person, and the other one has the address associated with it, if we do an intersection of these two data sources, it allows us to identify this person. Therefore, both of them contains personal data.&lt;/p&gt;

&lt;p&gt;On the other hand, the legal basis of consent is generally the easiest one to obtain, because the &lt;em&gt;data subject&lt;/em&gt; (to whom the data relates) can state that agrees with the collect and processing of their personal data, and does authorize the website's owner to do so in order to fulfill specific purposes, unless it does not violates any law or misuses this information.&lt;/p&gt;

&lt;p&gt;It means that these responsible for the website must be transparent, fair, and accurate at the time of collect. And if they want to transmit this data to third-parties, which GDPR refers to as &lt;em&gt;data processors&lt;/em&gt;, they must also act in accordance with the law and with the purposes that the contract between the parties was established.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 If you are a developer and want to adapt to these rules, you must obtain the explicit consent of the data subjects &lt;em&gt;before&lt;/em&gt; processing their personal information using cookies or any other third-party resources. Also, it is important to keep a log on when and how you obtained this consent, in a secure manner. You must also allow users to change their preferences later, revoking access to the information and deleting it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For those reasons, we are often seeing alerts and requests to allow cookies in order to continue using the website. But, what if we don't accept cookies? And if we don't agree to our personal data to be collected, processed and used, even within purposes permitted by law, what do we do?&lt;/p&gt;

&lt;p&gt;The answer is not simple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1cN9wgrJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atabeghfhge9qkwwqcvz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1cN9wgrJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atabeghfhge9qkwwqcvz.jpg" alt="Lawful basis of GDPR" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@polygraph?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Nicolás Varela&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why cookies?
&lt;/h2&gt;

&lt;p&gt;It happens that, in many cases, those responsible for the sites - we will call them, from now on, &lt;em&gt;data controllers&lt;/em&gt;, as GDPR did, but do not confuse them with &lt;em&gt;data processors,&lt;/em&gt; the third-parties, ok? - allows the user to choose which cookies are used. In general, most sites display a list where the user can select and allow just the ones they deem convenient. However, not all cookies can always be denied.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Although there is a few mentions on cookies in the GDPR and in the &lt;em&gt;ePrivacy Directive&lt;/em&gt;, another regulation that conducts this mechanisms, both data governance regulations &lt;a href="https://gdpr.eu/cookies/"&gt;must be interpreted together&lt;/a&gt;. For the purposes of this article, we will focus on GDPR only.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some cookies are vital to the website's functions, due to the nature of cookies: they store valuable information about the user's activity in the internet browser.&lt;/p&gt;

&lt;p&gt;The reason for cookies - or, &lt;em&gt;HTTP Cookies&lt;/em&gt;, the most appropriate technical term - is to allow webpages to store user's preferences and information while browsing. Cookies can temporarily save, as long as the duration of a session, for instance, user's login credentials for a social network, so it can prevent us to repeat the same step every time we click on a link or press &lt;em&gt;F5&lt;/em&gt; to refresh a page. Likewise, cookies may contain payment information for online shopping, responses to an electronic form, and other data.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Why do we call it cookies? The &lt;a href="https://www.cs.mcgill.ca/~rwest/wikispeedia/wpcd/wp/h/HTTP_cookie.htm"&gt;term is a derivation&lt;/a&gt; of "magic cookies", a concept of Unix computing for transmitting information between the sender and the receiver.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pdizqHXJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dr0a60f3scmx5k01m2sm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pdizqHXJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dr0a60f3scmx5k01m2sm.jpg" alt="Why cookies?" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@jontyson?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Jon Tyson&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For the purposes of this article, we will not cover the technical description on how cookies work. It is important, however, that you understand that cookies are important for storing user's session information, and work as "identification data" or "badge" on the server. Also, remember that cookies can contains personal and specific data about the user, and that's why that data controllers must implement good security practices in order to protect access and storage on their servers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 There is a recent discussion about new alternatives to cookies, such as Federated Cohort Learning (FLoC), &lt;a href="https://blog.google/products/ads-commerce/2021-01-privacy-sandbox/"&gt;endorsed by Google&lt;/a&gt;, which aims to cluster people with relevant interests into large groups. FLoC has not been implemented for the general audience yet, but many people have already expressed concerns about this technology that will impact the advertising and digital marketing, for privacy reasons mainly. But this controversy is a subject for another post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  More cookies, fewer banners?
&lt;/h3&gt;

&lt;p&gt;Now that we know what cookies are, and why they are necessary for websites, we can conclude that it is not easy for data controllers to choose to completely remove the banners and pop-ups windows that have been chasing us on almost all websites lately, calling for our attention in order to offer us some.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uzFgjnj3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ao428esbooz61665ep5a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uzFgjnj3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ao428esbooz61665ep5a.jpg" alt="Sharing is Caring" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Sharing is Caring", by &lt;a href="https://lightroastcomics.com/sharing-is-caring"&gt;Light Roast Comics&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Certainly, because data controllers must comply with specific laws and regulations, they cannot refrain from obtaining at least one of the lawful basis for processing users' personal data, but this does not mean that there are no other ways of doing it in a safe way, and also in accordance with GDPR, in compliance with the transparency and efficiency principles.&lt;/p&gt;

&lt;p&gt;On the other hand, the option to avoid banners and consider consent to be implied, however, is not a valid option, according to the &lt;a href="https://ico.org.uk/about-the-ico/news-and-events/news-and-blogs/2019/07/blog-cookies-what-does-good-look-like/"&gt;UK's Information Commissioner's Office&lt;/a&gt;: "your users must take a clear and positive action to consent to non-essential cookies". The same goes for pre-ticked checkboxes on &lt;em&gt;non-essential cookies&lt;/em&gt;: "pre-ticked boxes or any equivalents, such as sliders defaulted to ‘on’, cannot be used for non-essential cookies". In order to obtain the user's consent for cookies considered non-essential for the server's workings, is required a "positive action" by the user, that must consent to the collect and processing data by clicking on an "Allow" button, or by checking a "Consent" checkbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J24ZD0E7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgjzh19coe64phf82dv8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J24ZD0E7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgjzh19coe64phf82dv8.png" alt="React Cookie Notice" width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Example of cookie notice on a website. In this case, the &lt;a href="https://github.com/mirzalikic/react-cookie-notice"&gt;React Cookie Notice&lt;/a&gt; component.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If there are no other ways, after all, to obtain cookies, there are three possible options: (a) we can simply continue and accept it, which may displease the most concerned users about privacy and data protection; (b) suggest authorities to review and to regulate new rules on cookies and procedures for obtaining consent; or (c) seek less intrusive ways to obtaining consent and also the good practices in order to not negatively impact the user's experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changes may come
&lt;/h2&gt;

&lt;p&gt;In fact, criticisms on cookie consent policies have had an effect, and the European authorities have &lt;a href="https://www.theverge.com/2020/5/7/21250300/eu-cookie-consent-policy-updated-guidelines-cookie-wall"&gt;updated their guidelines&lt;/a&gt; on the interpretation of legal rules on this topic. However, the problem of thousands of pages displaying banners, pop-ups and their "cookie walls" still persists, and has raised questions even internationally.&lt;/p&gt;

&lt;p&gt;The privacy and data protection policy is a right as well as an obligation, as it ensures greater transparency to data subjects, while imposing the need for &lt;em&gt;accountability&lt;/em&gt; and &lt;em&gt;compliance&lt;/em&gt; for both data controllers and data processors. Also, the new rules have caused the phenomenon of "opt-in fatigue", which we hope will be resolved soon.&lt;/p&gt;

&lt;p&gt;Do you have any suggestion on how to solve the problem of so many opt-in on the webpages that we access? Don't you think it as a problem? Do you think there is something to be done on this way? Comment below your opinion or your suggestion about this subject. 📢&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;[1] &lt;em&gt;Data protection under GDPR&lt;/em&gt;. (2021, March 26). Your Europe. &lt;a href="https://europa.eu/youreurope/business/dealing-with-customers/data-protection/data-protection-gdpr/"&gt;https://europa.eu/youreurope/business/dealing-with-customers/data-protection/data-protection-gdpr/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[2] Koch, R. (2019, May 9). &lt;em&gt;Cookies, the GDPR, and the ePrivacy Directive&lt;/em&gt;. GDPR.EU. &lt;a href="https://gdpr.eu/cookies/"&gt;https://gdpr.eu/cookies/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[3] &lt;em&gt;Using HTTP cookies&lt;/em&gt; - HTTP | MDN. (2021, April 13). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; &lt;em&gt;This article does contains some legal information for educational purposes only, but does not contain legal advice on any subject matter. If you need professional advice regarding your specific circumstances, please consult your attorney.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>legal</category>
      <category>discuss</category>
    </item>
    <item>
      <title>HTML Standards for Better SEO: The HEAD element</title>
      <dc:creator>Danilo César</dc:creator>
      <pubDate>Tue, 06 Jul 2021 19:52:07 +0000</pubDate>
      <link>https://forem.com/danilo/html-standards-for-better-seo-the-head-element-1cck</link>
      <guid>https://forem.com/danilo/html-standards-for-better-seo-the-head-element-1cck</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is also available in the following languages: &lt;a href="https://danilocsar.medium.com/padr%C3%B5es-html-para-melhor-seo-o-elemento-head-9cf787bcad00" rel="noopener noreferrer"&gt;Portuguese&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;In this article, we will understand the basics of Search Engine Optimization (SEO), and of the HTML's format and syntax. We will also learn how to implement better tags on our websites, that can help us to reach better results on search engines, by investigating how they do work, and what are the meta tags that they understand.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;em&gt;If you are not familiar with the HTML syntax, you should check my article “&lt;a href="https://dev.to/danilo/css-and-html-explained-for-absolute-beginners-part-1-2hjd"&gt;CSS and HTML Explained for Absolute Beginners: Part 1&lt;/a&gt;” before continue on this current one, as some markup language knowledge may be necessary.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Suppose you are getting into a new author, and walk to the next bookstore, on your neighborhood, hoping that you will find this person's new book there. How do you start searching for it?&lt;/p&gt;

&lt;p&gt;There are many options that may help you on this job: (a) you ask the salesperson, by giving some information about the book; (b) you walk through the aisles, looking for the specific category where the book belongs; or, (c) you look at every single book in this bookstore, one by one, looking for the specific cover that contains the information you're looking for.&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%2Fuploads%2Farticles%2F03fstwvbifwwgxzpkqyj.jpg" 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%2Fuploads%2Farticles%2F03fstwvbifwwgxzpkqyj.jpg" alt="Shelf Bookcase Library"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Shelf Bookcase Library”, by &lt;a href="https://pixabay.com/users/deedee86-4642964/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=3195135" rel="noopener noreferrer"&gt;Deedee86&lt;/a&gt; from &lt;a href="https://pixabay.com/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=3195135" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As you can see, some of these choices may take a while, but they all have one thing in common: the document's metadata. It means there are some information on these objects that can be used for catalog, and also for better searching purposes.&lt;/p&gt;

&lt;p&gt;This is the basic of &lt;strong&gt;Search Engine Optimization&lt;/strong&gt;, or &lt;strong&gt;SEO techniques&lt;/strong&gt;, a process meant to optimize the way we search for specific things on the internet. Let's investigate how this works, and how we can develop better implementations on our websites or applications, in order to reach better positions when users search for specific keywords on their favorite search engines.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is SEO?
&lt;/h2&gt;

&lt;p&gt;Search Engine Optimization (SEO) is a set of techniques in order to make the web content search-friendly, by making the search engines “understand” our website, and lead users to find us. The small improvements that we make, result in more relevant users viewing our content, and also help us to promote and monetize web content.&lt;/p&gt;

&lt;p&gt;There are many experts on the internet that can help us to improve our visibility on those page's results, and also to provide useful services. Let's understand how we can apply some of these techniques by following the HTML standards.&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%2Fuploads%2Farticles%2F7mqwj0kho7wvzp23k4gn.jpg" 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%2Fuploads%2Farticles%2F7mqwj0kho7wvzp23k4gn.jpg" alt="Search Engine Optimization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Search Engine Optimization”, by &lt;a href="https://pixabay.com/pt/users/geralt-9301/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=1359429" rel="noopener noreferrer"&gt;Gerd Altmann&lt;/a&gt; from &lt;a href="https://pixabay.com/pt/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=1359429" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to insert meta tags in HTML
&lt;/h2&gt;

&lt;p&gt;Before we get started, take a minute to check the metadata information used on this current webpage.&lt;/p&gt;

&lt;p&gt;Above the web browser's address bar, the title, and the icon — a.k.a. &lt;em&gt;favicon&lt;/em&gt;, the “favorite icon” — are presented even before the page is fully rendered. See how our web browser already collect some of this data? Under the hood, when a request is made to a web server, our web browser is looking for information 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="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="na"&gt;dir=&lt;/span&gt;&lt;span class="s"&gt;"ltr"&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;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"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/favicon.png"&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;My simple web page&lt;span class="nt"&gt;&amp;lt;/title&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;"description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"In order to fully understand SEO, we have to start by the basics, learning its fundamentals."&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Some browsers provide better information about the metadata gathered from the current webpage. If you're using Mozilla Firefox, you can open the Site Information panel by pressing &lt;code&gt;Ctrl + I&lt;/code&gt; on your PC, or by following &lt;a href="https://support.mozilla.org/en-US/kb/site-information-panel" rel="noopener noreferrer"&gt;this guide&lt;/a&gt;. The opened window should look like this:&lt;/p&gt;
&lt;/blockquote&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%2Fuploads%2Farticles%2F4rombfoxm253qi48zaeo.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%2Fuploads%2Farticles%2F4rombfoxm253qi48zaeo.png" alt="Firefox's Site Information panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://stackoverflow.com/" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;'s homepage — &lt;a href="https://stackoverflow.blog/2017/03/09/anyone-actually-visit-stack-overflows-home-page/" rel="noopener noreferrer"&gt;yes, they do have a homepage!&lt;/a&gt; — seen in Firefox's Site Information panel.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even if you don't fully understand HTML yet, notice these pieces of information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The source-code tells the web browser that this is an HTML-type document;&lt;/li&gt;
&lt;li&gt;The second line specifies that the following HTML elements are displayed in the English language, and the “left-to-right” (&lt;code&gt;LTR&lt;/code&gt;) direction;&lt;/li&gt;
&lt;li&gt;There are some &lt;code&gt;viewport&lt;/code&gt; definitions for rendering the current webpage;&lt;/li&gt;
&lt;li&gt;There are, also, some values provided for the &lt;code&gt;icon&lt;/code&gt;, the &lt;code&gt;title&lt;/code&gt;, and a &lt;code&gt;description&lt;/code&gt; about this page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTML is not rocket science, so we can easily insert meta tags in our HTML file by adding it to the top of our content, inside the HTML's &lt;code&gt;head&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;head&lt;/code&gt; element is meant to provide some information about the page, such as rendering definitions, links, style-sheets, and scripts. Most of this metadata are not human-readable, and will not be displayed on the page, but will be only interpreted by the web server, and by the client's web browser.&lt;/p&gt;

&lt;p&gt;The search engines usually collect data from the &lt;code&gt;head&lt;/code&gt; element to provide better results, which means that we can insert meta tags to improve the visibility of our webpages and applications, like by following the HTML's formatting syntax.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML's formatting syntax
&lt;/h2&gt;

&lt;p&gt;The HTML's formatting syntax is the set of rules that structure an HTML file, so its content can be recognized by the web browser and correctly rendered for the users' navigation.&lt;/p&gt;

&lt;p&gt;There are many elements defined on the HTML Standards, and developers had also implemented non-standard elements and global attributes on their applications.&lt;/p&gt;

&lt;p&gt;For the purposes of this article, we will cover only some of those that can be understood by SEO techniques, so you can implement it on your own website or application to achieve better results.&lt;/p&gt;

&lt;h3&gt;
  
  
  The document element 📃
&lt;/h3&gt;

&lt;p&gt;The first step on creating an HTML file is actually informing that it &lt;em&gt;is&lt;/em&gt; an HTML file.&lt;/p&gt;

&lt;p&gt;According to the HTML Standard, by the &lt;a href="https://whatwg.org/" rel="noopener noreferrer"&gt;Web Hypertext Application Technology Working Group&lt;/a&gt; (WHATWG), a community founded by the leading web browser vendors in 2004:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;html&lt;/code&gt; element represents the root of an HTML document.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, it refers to the single element from where all the HTML's elements belong to. You can think it as &lt;em&gt;node tree&lt;/em&gt;: the whole document is a document node; so other HTML elements are hierarchical nodes, like this:&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%2Fuploads%2Farticles%2F5ip6jlnm5zxm23xbn628.gif" 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%2Fuploads%2Farticles%2F5ip6jlnm5zxm23xbn628.gif" alt="The HTML DOM nodes structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The HTML DOM nodes structure. Image from &lt;a href="https://www.w3schools.com/js/js_htmldom_navigation.asp" rel="noopener noreferrer"&gt;W3Schools&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The document tree 🌳
&lt;/h3&gt;

&lt;p&gt;The way most search engines work is by traveling relevant parts of the entire document, and then gathering information from its nodes, and creating relationships between the element and its content, such as texts, by looking for HTML's &lt;code&gt;p&lt;/code&gt; elements (for the paragraphs), or images and its caption — like &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption" rel="noopener noreferrer"&gt;this one&lt;/a&gt;:&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;figure&amp;gt;&lt;/span&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;"/media/cc0-images/elephant-660-480.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Elephant at sunset"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;figcaption&amp;gt;&lt;/span&gt;An elephant at sunset&lt;span class="nt"&gt;&amp;lt;/figcaption&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/figure&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;alt&lt;/code&gt; attribute on the example above: it can be used by screen readers, for blind and visually impaired people, so they can know what this image is about; but also for SEO purposes, as we can describe for the search engine what this figure is about, and how it's related to near text.&lt;/p&gt;

&lt;p&gt;Talking about &lt;strong&gt;web accessibility&lt;/strong&gt;, we should avoid placing texts &lt;em&gt;inside&lt;/em&gt; images, as it won't be read for many users. Instead, we can use a relevant image &lt;em&gt;near&lt;/em&gt; a piece of text explaining what this is about.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 The best practice is to place the most important figure near the top of the webpage, like a banner image, and the other images near its context, such as the relevant text or section's heading.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The document metadata 📔
&lt;/h3&gt;

&lt;p&gt;Another great way to provide information for the search engine is by using meta tags. In the HTML document, it can be provided right on the front matter, inside the &lt;code&gt;head&lt;/code&gt; element. For 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;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, maximum-scale=1.0"&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;"generator"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"WordPress 5.6"&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;The document metadata&lt;span class="nt"&gt;&amp;lt;/title&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;"author"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"John Doe"&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;"description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"This article explains the HTML metadata"&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;"keywords"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"html,metadata,rfc"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"alternate"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"application/atom+xml"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"blog-posts.xml"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"canonical"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"http://www.example.com/html/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"license"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://creativecommons.org/licenses/by/4.0/"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 According to the HTML5 Standard, &lt;em&gt;&lt;a href="https://html.spec.whatwg.org/multipage/syntax.html#void-elements" rel="noopener noreferrer"&gt;void elements&lt;/a&gt;&lt;/em&gt;, such as &lt;code&gt;link&lt;/code&gt; and &lt;code&gt;meta&lt;/code&gt; tags are &lt;em&gt;self-closing&lt;/em&gt;, as they don't have any content. It means you can end them by just typing &lt;code&gt;&amp;gt;&lt;/code&gt;, instead of &lt;code&gt;/&amp;gt;&lt;/code&gt;. Other &lt;em&gt;void elements&lt;/em&gt; include: &lt;code&gt;area&lt;/code&gt;, &lt;code&gt;base&lt;/code&gt;, &lt;code&gt;br&lt;/code&gt;, &lt;code&gt;col&lt;/code&gt;, &lt;code&gt;embed&lt;/code&gt;, &lt;code&gt;hr&lt;/code&gt;, &lt;code&gt;img&lt;/code&gt;, &lt;code&gt;input&lt;/code&gt;, &lt;code&gt;param&lt;/code&gt;, &lt;code&gt;source&lt;/code&gt;, &lt;code&gt;track&lt;/code&gt;, and &lt;code&gt;wbr&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's understand each one of these elements used in our example code.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML head elements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The meta tag 🧬
&lt;/h3&gt;

&lt;p&gt;First, the &lt;code&gt;meta&lt;/code&gt; tag is used for defining metadata about the HTML file, and can modify the way web browsers render the document.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt; has a great list about the values that can be assigned to the meta tag's &lt;code&gt;name&lt;/code&gt; attribute, such as &lt;code&gt;author&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;generator&lt;/code&gt;, and &lt;code&gt;keywords&lt;/code&gt;. Most of them are self-descriptive, and automatically informed by modern frameworks already.&lt;/p&gt;

&lt;p&gt;Let's revisit our previous example. The first three meta tags can be useful: (i) to inform the characters encoding — we're using &lt;code&gt;UTF-8&lt;/code&gt;, the default &lt;code&gt;charset&lt;/code&gt; —; (ii) to specify the device's size (also to enable the responsive behavior); and (iii) to identify the software that generated the webpage.&lt;/p&gt;

&lt;p&gt;These three lines below can be used to describe the name of one of the page's authors, a brief summary of the document — modern web browsers may use it as the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name" rel="noopener noreferrer"&gt;default description&lt;/a&gt; of bookmarked pages —, and some keywords (separated by comma) related to the current page's 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;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"author"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"John Doe"&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;"description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"This article explains the HTML metadata"&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;"keywords"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"html,metadata,rfc"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Most of the search engines use this metadata to provide a short description of the webpage on their results, so using a good mix of keyword phrases can lead us to make better results. But be careful: numerous unnecessary keywords should be avoided, as they may harm your position.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If dealing with explicit content, it is strongly recommended by most of the search engines to specify the &lt;code&gt;rating&lt;/code&gt; metadata, so it won't be included in the search results for users that are not allowed, don't want, or don't expect to find these, when using search filters, like Google's &lt;a href="https://developers.google.com/search/docs/advanced/guidelines/google-images?hl=cs#safe_search" rel="noopener noreferrer"&gt;SafeSearch&lt;/a&gt;. It can be done by including one of the following meta tags:&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;"rating"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"adult"&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;"rating"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"RTA-5042-1996-1400-1577-RTA"&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;Another thing to notice about the meta tag is that many search engines may change the search result title if they notice an alternative text, inside the webpage's content, that better indicates their relevance to the users' query. According to &lt;a href="https://developers.google.com/search/docs/advanced/appearance/good-titles-snippets?hl=cs#why-the-search-result-title-might-differ-from-the-pages-title-tag" rel="noopener noreferrer"&gt;Google Search Central&lt;/a&gt;, it occurs when “the title tag as specified by a website owner is limited to being static, fixed regardless of the query”, so the search result title might differ from the &lt;code&gt;title&lt;/code&gt; tag defined in the HTML file.&lt;/p&gt;

&lt;h3&gt;
  
  
  The link tag ⛓️
&lt;/h3&gt;

&lt;p&gt;Sometimes, developers need to establish connections to use external resources from a different location, for many reasons, such as to avoid repetition of code and patterns, so replacing it with another source also reduces the size of the single file. This can be done by using the &lt;code&gt;link&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;The External Resource Link element, the HTML's &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag, tells the web browser to get this file, and use its content in the current web page. For 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;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"favicon.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&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;"default-stylesheet.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&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://example.com/css/print.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"print"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&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;"mobile.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"screen and (max-width: 576px)"&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;In this example, we are informing the browser to locate the default CSS file, used for most of the media types, in the &lt;code&gt;default-stylesheet.css&lt;/code&gt;. Notice that files can also be located outside the current page's directory, as we are reaching the &lt;code&gt;https://example.com/css/print.css&lt;/code&gt; file from a different web server.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;media&lt;/code&gt; attribute specifies that this resource should only be used by the web browser when the media condition is true. So, in our example, if we are trying to print this web page, our web browser will render the page according to the style-sheets located in that file.&lt;/p&gt;

&lt;p&gt;For targeting printers, we can add our code inside the &lt;em&gt;media breakpoint&lt;/em&gt; in our CSS file, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;print&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.banner&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffffff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 HTML respects the order of the information provided, so we can set a new CSS file to override the previous one: by adding an external resource link element after the &lt;code&gt;default-stylesheet.css&lt;/code&gt; line, in our example.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The same applies to the &lt;code&gt;mobile.css&lt;/code&gt; file: if we are opening this page on a device which screen is 576px or less, the browser will render the webpage according to its file.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 There are some common breakpoints, based on the general screen size ranges, such as: &lt;strong&gt;576px&lt;/strong&gt; (small devices), &lt;strong&gt;768px&lt;/strong&gt; (medium devices), &lt;strong&gt;992px&lt;/strong&gt; (large devices), and &lt;strong&gt;1200px&lt;/strong&gt; (extra-large devices).&lt;/p&gt;
&lt;/blockquote&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%2Fuploads%2Farticles%2Fseqofhkg19hoq3jzsdym.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%2Fuploads%2Farticles%2Fseqofhkg19hoq3jzsdym.png" alt="Responsive Web Design"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Responsive Web Design”, by &lt;a href="https://pixabay.com/users/clovis_cheminot-949172/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=1166833" rel="noopener noreferrer"&gt;Clovis Cheminot&lt;/a&gt; from &lt;a href="https://pixabay.com/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=1166833" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For better SEO results, we should use the &lt;code&gt;rel&lt;/code&gt; attribute as well, that can set a relationship between some linked resources and our current webpage.&lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt;, the &lt;code&gt;rel&lt;/code&gt; attribute must express tokens that are semantically valid for both machines and humans. In our example, we already used three of them:&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;rel=&lt;/span&gt;&lt;span class="s"&gt;"alternate"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"application/atom+xml"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"blog-posts.xml"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"canonical"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"http://www.example.com/html/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"license"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://creativecommons.org/licenses/by/4.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;Let's understand what does each one of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;alternate&lt;/code&gt; value describes other representations of the current document, such as a syndication feed, or an alternative format and language, intended for other media types. In our example, we are demonstrating that there is an Atom Feed for our blog-posts as an alternate representation.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;canonical&lt;/code&gt; value should be use if there is a single page that can be accessed on multiple URLs, or different pages containing the same content. It may occur when there are duplicate versions of the same page, such as &lt;code&gt;example.com/html/&lt;/code&gt; and &lt;code&gt;example.com/?p=html&lt;/code&gt;, so all the other URLs with similar content will be considered &lt;em&gt;duplicate&lt;/em&gt; URLs and &lt;em&gt;crawled&lt;/em&gt; less often.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Many developers usually post the same content on multiple blogging platform, or information channels, to engage a larger audience. This technique is known as “crossposting”, and should be used along with the &lt;code&gt;canonical&lt;/code&gt; URL, so search engines can prioritize the one that is the most representative from a set of the duplicate pages.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;license&lt;/code&gt; value indicates the licensing information for the current element or webpage. It can be used on the &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;area&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;, or &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; HTML elements, and so provided a hyperlink with the rules and declarations, 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;a&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"license"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"http://creativecommons.org/licenses/by/4.0/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Creative Commons License"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"border-width:0"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://i.creativecommons.org/l/by/4.0/88x31.png"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;This work is licensed under a &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"license"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"http://creativecommons.org/licenses/by/4.0/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Creative Commons Attribution 4.0 International License&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 The synonym &lt;code&gt;copyright&lt;/code&gt; is incorrect and must be avoided, although recognized by many web browsers and search engines.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;code&gt;link&lt;/code&gt; tag, however, can't be used for loading scripts: instead, we can use the &lt;code&gt;script&lt;/code&gt; tag.&lt;/p&gt;

&lt;h3&gt;
  
  
  The script tag 🕹️
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;script&lt;/code&gt; tag is used for embed executable code, and is typically used to include JavaScript code. It can also contain data, such as JSON (JavaScript Object Notation), that can be processed in our web page or application.&lt;/p&gt;

&lt;p&gt;As well as the &lt;code&gt;link&lt;/code&gt; tags, &lt;code&gt;script&lt;/code&gt; elements can refer to JavaScript code located in another web server or directory, like this 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;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"&lt;/span&gt; &lt;span class="na"&gt;integrity=&lt;/span&gt;&lt;span class="s"&gt;"sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="&lt;/span&gt; &lt;span class="na"&gt;crossorigin=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice we are using the &lt;code&gt;integrity&lt;/code&gt; and the &lt;code&gt;crossorigin&lt;/code&gt; attributes when adding this request to an external web server. It is a good practice, in order to create more secure applications that the web browser check the response.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;integrity&lt;/code&gt; attribute prevents web browser to load content that doesn't match with the expected response from the web server. It contains a &lt;em&gt;hash&lt;/em&gt; of a resource as its value, that ensures that the file was received unmodified and delivered without unexpected manipulation.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;crossorigin&lt;/code&gt; attribute defines how the element handles &lt;em&gt;cross-origin requests&lt;/em&gt;, by adding an &lt;code&gt;Origin&lt;/code&gt; field into the &lt;em&gt;HTTP Request&lt;/em&gt; to a server from a different origin. It provides support for &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" rel="noopener noreferrer"&gt;Cross-Origin Resource Sharing (CORS)&lt;/a&gt; mechanism, and can be set to either &lt;code&gt;anonymous&lt;/code&gt; (default), or &lt;code&gt;use-credentials&lt;/code&gt; values: the first one creates CORS requests with the credentials flag set to &lt;code&gt;same-origin&lt;/code&gt;; the second one, with the credentials flag set to &lt;code&gt;include&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our example, the web browser won't execute the code if the delivered file doesn't match with the hash that was informed, using the &lt;em&gt;SHA-256&lt;/em&gt; cryptographic hash algorithm.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 HTML's &lt;code&gt;link&lt;/code&gt; and &lt;code&gt;script&lt;/code&gt; tags can implement the &lt;code&gt;integrity&lt;/code&gt; and &lt;code&gt;crossorigin&lt;/code&gt; in order to provide better security, by allowing proper verification of the received data and its source.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That code can be implemented in the &lt;code&gt;head&lt;/code&gt; or in the &lt;code&gt;body&lt;/code&gt; of our HTML file, so the web browser would request for the file before or after the page's content is fully loaded. Also, it can be loaded in parallel with the rendering of the webpage's elements, asynchronously, or synchronously.&lt;/p&gt;

&lt;p&gt;Developers typically insert the &lt;code&gt;script&lt;/code&gt; element right after all the elements of the webpage are defined: in general, this way you can ensure the user will not be presented to a blank page until all the scripts are loaded, what can take some time depending on the users' network.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 For the purposes of this article, we won't cover the pros and cons of inserting the &lt;code&gt;script&lt;/code&gt; element on the &lt;code&gt;head&lt;/code&gt; or the &lt;code&gt;body&lt;/code&gt; element yet, nor doing it synchronously or asynchronously, as these topics require an article for themselves. In fact, you can follow this series as we will learn it in another time.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In SEO terms, placing the &lt;code&gt;link&lt;/code&gt; and &lt;code&gt;script&lt;/code&gt; tags inside the &lt;code&gt;head&lt;/code&gt; or &lt;code&gt;body&lt;/code&gt; element shouldn't matter, as search engine &lt;em&gt;crawlers&lt;/em&gt; usually won't read scripts or style-sheets, rather than our HTML content. On the other hand, their placement may impact users' experience, and the order of their declarations matter to other scripts that use them as dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We're done, so let's recap. We covered the basics of SEO techniques, and how to insert meta tags using HTML. Then, we learned about the document's elements and tree. Finally, we covered a few HTML head elements, such as the &lt;code&gt;meta&lt;/code&gt;, &lt;code&gt;link&lt;/code&gt;, and &lt;code&gt;script&lt;/code&gt; tags, and how to use it correctly in order to achieve better search engine results.&lt;/p&gt;

&lt;p&gt;In the next article of this series, we will cover the HTML's &lt;code&gt;body&lt;/code&gt; element, and how it can be implemented for better SEO results. Make sure to follow it. 🏆&lt;/p&gt;

&lt;h3&gt;
  
  
  Next steps 🚶
&lt;/h3&gt;

&lt;p&gt;There are many protocols that enhances the power of SEO techniques, and we can apply them to our webpage, in order to make better results. If you'd like to know about them, make sure to follow this series, as we will continue exploring how to make use of better SEO techniques.&lt;/p&gt;

&lt;p&gt;If you have any questions or suggestions about these subjects, please make a comment below. 📣&lt;/p&gt;

&lt;h3&gt;
  
  
  References 🧩
&lt;/h3&gt;

&lt;p&gt;[1] The Document Metadata (Header) element - HTML: HyperText Markup Language | MDN. (2021, June 2). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[2] The External Resource Link element - HTML: HyperText Markup Language | MDN. (2021, June 9). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[3] The metadata element - HTML: HyperText Markup Language | MDN. (2021, June 2). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[4] The Script element - HTML: HyperText Markup Language | MDN. (2021, June 2). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[5] Consolidate Duplicate URLs with Canonicals | Google Search Central. (n.d.). Google Developers. Retrieved July 5, 2021, from &lt;a href="https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls" rel="noopener noreferrer"&gt;https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[6] HTML attribute: crossorigin - HTML: HyperText Markup Language | MDN. (2021, May 26). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[7] HTML attribute: rel - HTML: HyperText Markup Language | MDN. (2021, June 22). MDN Web Docs. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[8] HTML Standard. (2021). WHATWG. &lt;a href="https://html.spec.whatwg.org/" rel="noopener noreferrer"&gt;https://html.spec.whatwg.org/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[9] SEO Starter Guide: The Basics | Google Search Central. (n.d.). Google Developers. Retrieved July 2, 2021, from &lt;a href="https://developers.google.com/search/docs/beginner/seo-starter-guide" rel="noopener noreferrer"&gt;https://developers.google.com/search/docs/beginner/seo-starter-guide&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>beginners</category>
      <category>seo</category>
    </item>
    <item>
      <title>CSS and HTML Explained for Absolute Beginners: Part 1</title>
      <dc:creator>Danilo César</dc:creator>
      <pubDate>Fri, 18 Jun 2021 20:38:28 +0000</pubDate>
      <link>https://forem.com/danilo/css-and-html-explained-for-absolute-beginners-part-1-2hjd</link>
      <guid>https://forem.com/danilo/css-and-html-explained-for-absolute-beginners-part-1-2hjd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is also available in the following languages: &lt;a href="https://danilocsar.medium.com/css-e-html-explicados-para-iniciantes-parte-1-beacb2007299" rel="noopener noreferrer"&gt;Portuguese&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;A few people have said in the past that the best way to learn something is by teaching others. So, here is my attempt to explain CSS and HTML languages in layperson terms, so absolute beginners can follow these steps in order to start a journey into the web development area.&lt;/em&gt; 🧑‍💻&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In this article, we will be covering what does both CSS and HTML actually means, and how developers can build web pages using these languages. The logic behind it is similar to drawing. You wonder how?&lt;/em&gt; 🧑‍🎨&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;You are probably a better artist than I am, but I am sure you at least once started a drawing like this: at first, you draw a head, a very well-known circle one; and then, made a stick body, with upper and lower members coming out of it.&lt;/p&gt;

&lt;p&gt;Your drawing probably looked like this:&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%2Fuploads%2Farticles%2F3j4ia4yzyxvm5l2ok95q.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%2Fuploads%2Farticles%2F3j4ia4yzyxvm5l2ok95q.png" alt="Three stick figures"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Image by Monika Zagrobelna on "&lt;a href="https://design.tutsplus.com/tutorials/how-to-draw-a-stick-figure-a-complex-guide--cms-23620" rel="noopener noreferrer"&gt;How to Draw a Stick Figure: a Complex Guide&lt;/a&gt;"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, how does it relate to CSS and HTML? I am glad you ask!&lt;/p&gt;

&lt;p&gt;If you want a web browser to know the structure, in order to render a web page, you must present it a structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML, and the page structure 🏋️
&lt;/h2&gt;

&lt;p&gt;So here comes the &lt;a href="https://html.spec.whatwg.org/" rel="noopener noreferrer"&gt;HyperText Markup Language&lt;/a&gt; (or its acronym, the HTML): it tells the web browser where the elements are located, and how do they exist.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 As you noticed, by its definition, &lt;strong&gt;HTML is a markup language, not a programming language&lt;/strong&gt;. It does not use any variables or functions, so we can't make a full-functional application, nor interact directly with the elements on the page. To do this, we can use JavaScript or any other programming language.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By default, the most modern web browsers know how to render a paragraph, a button, or an input even if you don't tell them how it should appear. It's defined by the &lt;a href="https://html.spec.whatwg.org/" rel="noopener noreferrer"&gt;HTML Standard&lt;/a&gt; and by the vendor default &lt;a href="https://www.w3.org/Style/CSS/" rel="noopener noreferrer"&gt;CSS style-sheets&lt;/a&gt; in most browsers.&lt;/p&gt;

&lt;p&gt;Actually, they don't look all the same on every web browser. So, there are some plugins that help developers by making it look “normalized”, such as &lt;a href="https://github.com/necolas/normalize.css" rel="noopener noreferrer"&gt;normalize.css&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, in the HTML, we can make the web browser to behavior in certain ways, by importing a few “libraries” (that can help developers, as they contain many functions, so they don't have to write, or create, all that by themselves over and over again), and by containing some metadata, such as the &lt;code&gt;title&lt;/code&gt;, the &lt;code&gt;language&lt;/code&gt;, the &lt;code&gt;viewport&lt;/code&gt; and the characters &lt;code&gt;encoding&lt;/code&gt; standard (usually, developers use &lt;code&gt;UTF-8&lt;/code&gt;, because it contains a lot of entities that we are used to reading in English).&lt;/p&gt;

&lt;p&gt;Those libraries and metadata are too important in order to make the web browser render the page well, so we may want to load it before the web browser ends the rendering task. That's why we usually call it at the &lt;code&gt;head&lt;/code&gt;, just before the browser knows what are the elements or how do they look.&lt;/p&gt;

&lt;p&gt;The elements, right after the &lt;code&gt;head&lt;/code&gt; being loaded, are located in the &lt;code&gt;body&lt;/code&gt; structure. And they can be nested, just like branches on a tree.&lt;/p&gt;

&lt;p&gt;So, that's the basic structure of the HTML, or the structure of a web page. A real-page may look 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="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-US"&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;title&amp;gt;&lt;/span&gt;Here goes the Page's 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;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;This is a big heading&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;And this is a paragraph.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &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;Notice how this markup language works: the elements, such as the &lt;code&gt;title&lt;/code&gt;, the heading &lt;code&gt;h1&lt;/code&gt;, and the paragraph (&lt;code&gt;p&lt;/code&gt;) are expressed starting with &lt;code&gt;&amp;lt;&lt;/code&gt;, and ending with &lt;code&gt;/&amp;gt;&lt;/code&gt;. Also, there are two elements “inside” the &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; one: the &lt;code&gt;head&lt;/code&gt;, that contains the &lt;code&gt;title&lt;/code&gt; element; and the &lt;code&gt;body&lt;/code&gt;, where most of the elements are located, and displayed on web browser.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Don't worry if you don't fully understand what this code does yet. We are just getting started, and if you reach this part, well done, you are really making progress! 👏&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  CSS, and the page look 💄
&lt;/h2&gt;

&lt;p&gt;Now, let's go back to our drawing. We sure can make it look more elegant, funny, or even sexy. So, let's put some color into our character-friend.&lt;/p&gt;

&lt;p&gt;We can change how do the elements, or how the whole page, looks, as we can put some colors and effects into our drawing. To illustrate that, we can turn our design into a completely different and professional look, like the “Unfinished Horse Drawing” that you are probably familiar with it:&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%2Fuploads%2Farticles%2Fso4h2kq6830tgpj9cur6.jpeg" 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%2Fuploads%2Farticles%2Fso4h2kq6830tgpj9cur6.jpeg" alt="Unfinished Horse Drawing by Ali Bati"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Unfinished Horse Drawing”, by Ali Bati, on &lt;a href="https://knowyourmeme.com/memes/unfinished-horse-drawing" rel="noopener noreferrer"&gt;Know Your Meme&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's the magic of the CSS, or the &lt;a href="https://www.w3.org/Style/CSS/Overview.en.html" rel="noopener noreferrer"&gt;Cascading Style Sheets&lt;/a&gt;: it tells the web browser how these elements, and the web page's structure, should look, in order to make it successfully rendered.&lt;/p&gt;

&lt;p&gt;By tweaking our CSS file — you can include it on the &lt;code&gt;head&lt;/code&gt;, or on the &lt;code&gt;body&lt;/code&gt; as well, in our HTML file, depending on &lt;em&gt;when&lt;/em&gt; we want it to load by the browser —, the changes will apply whenever we open the page, or right after all the elements are rendered.&lt;/p&gt;

&lt;p&gt;CSS can make changes to the structure as well. It can contain rules to create columns or rows for the elements to show, for example. Also, CSS can rule the elements' positions related to each other on the three-dimensional space(!).&lt;/p&gt;

&lt;p&gt;You probably familiar with the &lt;code&gt;X&lt;/code&gt;, &lt;code&gt;Y&lt;/code&gt; and &lt;code&gt;Z&lt;/code&gt; axis, right? In the CSS file, we can change the position and the scale of the elements, but also the &lt;code&gt;z-index&lt;/code&gt;, that tells the order of the elements related to each other: elements with lower values are positioned backwards, and higher values, on the front, just like a 3D image.&lt;/p&gt;

&lt;p&gt;A simple CSS file may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;32px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Cascading Style-Sheet syntax is different from the previous markup language: the elements are identified by their selector, such as the &lt;code&gt;h1&lt;/code&gt; there; then followed by a property and its value, like the &lt;code&gt;color: blue;&lt;/code&gt; in our example; the declarations containing property and values are typed inside the &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; characters.&lt;/p&gt;

&lt;p&gt;There are lots of great tutorials on how to create good-looking web pages, templates, and design trends for free on the internet — you can check it later, using the &lt;a href="https://dev.to/t/webdev"&gt;#web-development&lt;/a&gt;, &lt;a href="https://dev.to/t/design"&gt;#design&lt;/a&gt; and &lt;a href="https://dev.to/t/css"&gt;#css&lt;/a&gt; tags, for example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap 🧩
&lt;/h2&gt;

&lt;p&gt;We're done, so let's recap. We went through the basics on HTML, and learned about the &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;body&lt;/code&gt; structure, that contains the elements and tell the browser how to render the page correctly. We also covered the basics on CSS, that is capable of changing the web page's look and feel, and how the elements appear &lt;em&gt;before&lt;/em&gt; and &lt;em&gt;after&lt;/em&gt; the page is successfully loaded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion 🎉
&lt;/h2&gt;

&lt;p&gt;The HTML5 and CSS3 (the current and latest versions of each one) can be used to create animations, patterns, and even interactive games. Browsers are also becoming much more smart, as developers are creating new tools and technical specifications in order to solve many problems nowadays.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;UI&lt;/em&gt; (User Interface) and the &lt;em&gt;UX&lt;/em&gt; (User Experience) are crafting new ways to use those style-sheets and structures too, by making things beautiful and useful interfaces to us, the web users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next steps 🚶‍♂️
&lt;/h3&gt;

&lt;p&gt;Now that we understand the basics on CSS and HTML, let me invite you to follow this series, so we can go even further on learning about web development. On the next article, we will be covering how to build a web page from scratch using these languages.&lt;/p&gt;

&lt;p&gt;What do you think could be the next big thing developers may create on the upcoming new versions, like the HTML6 or CSS4? And, what kind of design do you want to achieve on the next steps? Tell us in the comments. 📢&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;[1] “CSS: Cascading Style Sheets”, from MDN Web Docs: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[2] “CSS Introduction”, from W3Schools: &lt;a href="https://www.w3schools.com/css/css_intro.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/css/css_intro.asp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[3] “HTML: HyperText Markup Language”, from MDN Web Docs: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[4] “HTML Standard”, from WHATWG community: &lt;a href="https://html.spec.whatwg.org/" rel="noopener noreferrer"&gt;https://html.spec.whatwg.org/&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Understanding Cross-Site Request Forgery (CSRF or XSRF)</title>
      <dc:creator>Danilo César</dc:creator>
      <pubDate>Wed, 09 Jun 2021 01:14:31 +0000</pubDate>
      <link>https://forem.com/danilo/understanding-cross-site-request-forgery-csrf-or-xsrf-3d95</link>
      <guid>https://forem.com/danilo/understanding-cross-site-request-forgery-csrf-or-xsrf-3d95</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is also available in the following languages: &lt;a href="https://danilocsar.medium.com/entendendo-cross-site-request-forgery-csrf-ou-xsrf-1a5f2ed35a0d" rel="noopener noreferrer"&gt;Portuguese&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;On the last article we have learned how we can prevent some&lt;/em&gt; Cross-Site Scripting &lt;em&gt;(XSS) attacks by using proper sanitization techniques on our web server. Now, let's take a look at another vulnerability that also can cause problems on web pages that are not complying with the adequate security methods.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 If you did not read the previous article on this series, “&lt;a href="https://dev.to/danilo/secure-get-and-post-requests-using-php-k50"&gt;Secure GET and POST requests using PHP&lt;/a&gt;”, I suggest you to do, as some knowledge on what are &lt;em&gt;HTTP Requests&lt;/em&gt;, and how they do work, may be required in order to understand the following concepts — and, also, it can help you to increase your webpages' security.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Let's investigate another one of the most common web vulnerabilities: the &lt;em&gt;Cross-Site Request Forgery&lt;/em&gt; (CSRF), that tricks unwary users by making them execute unwanted actions on other web pages that they are already authenticated.&lt;/p&gt;

&lt;p&gt;For a better illustration on the problem, let's suppose this scenario: you are logged in on your bank's account, which web server is not aware of best practices on web development; you noticed a strange transaction involving a person or a company you never heard about; on another browser's tab, you search for their name, and accessed their website. Now, even if you did not authenticate or connect to your bank's account into this unknown web page, and did not use a (secure) third-party challenge-response systems, our fictional malicious web page may already change your password, transferred your funds, or made a purchase using your credentials.&lt;/p&gt;

&lt;p&gt;Sounds scary, right? Even that most modern browsers are committed to create “sandboxes” and limiting cookies' usage that are not on same-site's policy, there are many users on the world wide web using outdated web browsers, and clicking on every link that pops up on their monitors — most of them claiming that the user is a winner for entering the site on this specific date and time, or for completing a survey that they did not even hear about.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1623200215957%2Fq010wJ8jR.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1623200215957%2Fq010wJ8jR.png" alt="Entrepreneur in Tin Can with String - Vector Image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tin can conversation. Designed by &lt;a href="https://www.wannapik.com" rel="noopener noreferrer"&gt;Wannapik&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the past, some of the most accessed websites on the internet had suffered some sort of attacks related to CSRF, like &lt;a href="http://www.internetnews.com/security/article.php/3835596/Facebook+Hit+by+CrossSite+Request+Forgery+Attack.htm" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;, &lt;a href="http://blog.internetnews.com/skerner/2008/02/black-hat-netflix-csrf-vulnera.html" rel="noopener noreferrer"&gt;Netflix&lt;/a&gt;, &lt;a href="http://www.internetnews.com/security/article.php/3717106" rel="noopener noreferrer"&gt;Gmail&lt;/a&gt;, &lt;a href="https://people.eecs.berkeley.edu/~daw/teaching/cs261-f11/reading/csrf.pdf" rel="noopener noreferrer"&gt;YouTube, and the New York Times&lt;/a&gt;, but also web applications, such as &lt;a href="http://blog.internetnews.com/skerner/2009/04/mozilla-firefox-309-fixes-xss.html" rel="noopener noreferrer"&gt;Mozilla Firefox&lt;/a&gt; and the &lt;a href="http://www.internetnews.com/security/article.php/3777276/Apple+Updates+to+Fix+Open+Source+Security+Issues.htm" rel="noopener noreferrer"&gt;Apache HTTP Server&lt;/a&gt;. According to &lt;a href="https://people.eecs.berkeley.edu/~daw/teaching/cs261-f11/reading/csrf.pdf" rel="noopener noreferrer"&gt;this paper&lt;/a&gt;, many of them have already solved the problems, and others, thanks to the open developer community, fixed it as well.&lt;/p&gt;

&lt;p&gt;By performing unwanted functions on legitimate user's session, those bad agents use &lt;em&gt;their&lt;/em&gt; web links to initiate any arbitrary action they want on &lt;em&gt;our&lt;/em&gt; website, which had already validated user's session cookie, and have it stored. That's the worst part on XSRF attack: it does not solely rely on the website's administrator behalf, it depends on how browsers work, and on users' behavior too.&lt;/p&gt;

&lt;h2&gt;
  
  
  How CSRF works
&lt;/h2&gt;

&lt;p&gt;Let's revisit our example of the malicious page that performed an attack without the user's knowledge.&lt;/p&gt;

&lt;p&gt;The first condition to the CSRF attack successfully works is a situation where the legitimate user is logged in on a trustful website, by keeping a session information such as &lt;em&gt;HTTP Cookies&lt;/em&gt;, that also ensures shorthand verification of the users' credentials, so they don't need to inform their username and password on every request to the web server.&lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt;, &lt;em&gt;HTTP&lt;/em&gt; Cookies are typically used to tell if two requests came from the same browser. Also, they remember stateful information for the stateless &lt;em&gt;HTTP&lt;/em&gt; protocol, or encrypted &lt;em&gt;HTTPS&lt;/em&gt; protocol.&lt;/p&gt;

&lt;p&gt;The second condition is a request coming from a malicious website that makes the user's browser send a request to the web server where the user is previously authenticated, by doing a &lt;em&gt;GET&lt;/em&gt; or &lt;em&gt;POST&lt;/em&gt; request. It can be done, for example, by creating a web form, using HTML, whose target page is an unsecure web page on the trustful server.&lt;/p&gt;

&lt;p&gt;In simple terms, the &lt;em&gt;Cross-Site Request Forgery&lt;/em&gt; (CSRF) attack forges the request that is being sent to a trustful web server, so it is “crossing sites”. The following figure explains how does the CSRF attack work: the attacking site uses the users' authenticated session on the web browser in order to execute a trusted action on a trusted website.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1623200278583%2Fdo7nHydAP.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1623200278583%2Fdo7nHydAP.png" alt="souza2009.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Image: Souza, 2009.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For the purposes of this article, we will not cover this method on real-world applications, as our goal is not exploit any service, but, instead, to develop better implementations for the web.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example #1: &lt;em&gt;HTTP POST&lt;/em&gt; method
&lt;/h3&gt;

&lt;p&gt;If the target page isn't CSRF-protected, those bad agents can successfully do whatever they want using the user's credentials. For 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;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"evil-form"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"http://my.trustful.bank/transfer?amount=123&amp;amp;account=stevie"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&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;Click here&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&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;In this example, assume the page does really exist on the internet, and so the &lt;code&gt;trustful.bank&lt;/code&gt; uses an &lt;em&gt;HTTP&lt;/em&gt; request to send the amount of &lt;code&gt;123&lt;/code&gt; dollars to a client identified as &lt;code&gt;stevie&lt;/code&gt;, on the page &lt;code&gt;/transfer-funds&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 This is not a good practice, so I am sure your (real) bank is secure, and protected against it. If they are not, like any other web server, the consequences would be devastating, and it may cause some legal issues, as they wouldn't be complying with most of the Data Privacy and Protection Regulations, such as &lt;a href="https://en.wikipedia.org/wiki/General_Data_Protection_Regulation" rel="noopener noreferrer"&gt;GDPR 🇪🇺&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/General_Personal_Data_Protection_Law" rel="noopener noreferrer"&gt;LGPD 🇧🇷&lt;/a&gt;, nowadays.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Example #2: Automatic behavior
&lt;/h3&gt;

&lt;p&gt;Those bad agents don't even need the user directly interacting with the submit button in order to achieve the sending result. They could, for example, change it to an &lt;code&gt;onload&lt;/code&gt; event that fires whenever the user's browser renders the page, 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;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;onload=&lt;/span&gt;&lt;span class="s"&gt;"document.getElementById('evil-form').submit();"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"evil-form"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"http://my.trustful.bank/transfer"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&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;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"account"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"stevie"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&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;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"amount"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"123"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&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;Click here&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&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;Also, many web servers allow both &lt;em&gt;HTTP&lt;/em&gt; &lt;em&gt;GET&lt;/em&gt; and &lt;em&gt;POST&lt;/em&gt; requests, so CSRF attacks could probably work on both of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example #3: Without web forms
&lt;/h3&gt;

&lt;p&gt;It goes even worse, as bad agents are not limited to the HTML web forms. They can use, for example, a simple &lt;code&gt;img&lt;/code&gt; tag, 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;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&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;"http://my.trustful.bank/transfer?amount=123&amp;amp;to=stevie"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&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;This attack can also force a user to follow a redirection, by inserting it on the &lt;code&gt;httpd.conf&lt;/code&gt; or &lt;code&gt;.htaccess&lt;/code&gt; file on their web server, like this examples taken from “&lt;a href="https://www.amazon.com/XSS-Attacks-Scripting-Exploits-Defense/dp/1597491543" rel="noopener noreferrer"&gt;XSS Attacks: Cross Site Scripting Exploits and Defense&lt;/a&gt;” (2007) book:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;Redirect 302 /a.jpg https://somebank.com/transferfunds.asp?amnt=1000000&lt;span class="err"&gt;&amp;amp;&lt;/span&gt;acct=123456
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It would produce a request as the following one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /a.jpg HTTP/1.0
Host: ha.ckers.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Accept: image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://somebank.com/board.asp?id=692381
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the following server response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 302 Found
Date: Fri, 23 Mar 2007 18:22:07 GMT
Server: Apache
Location: https://somebank.com/transferfunds.asp?amnt=1000000&amp;amp;acct=123456
Content-Length: 251
Connection: close
Content-Type: text/html; charset=iso-8859-1

&amp;lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&amp;gt;
&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;302 Found&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Found&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;The document has moved &amp;lt;a href="https://somebank.com/transferfunds.asp?amnt=1000000&amp;amp;amp;acct=123456"&amp;gt;here&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, whenever the web browser performs the redirection, it will follow back to the informed location with the &lt;em&gt;HTTP Cookies&lt;/em&gt; intact, but the referring &lt;em&gt;URL&lt;/em&gt; may not change to the redirection page, what makes it even worse, because the user may not easily detect on referring *URL*s.&lt;/p&gt;

&lt;p&gt;Who could imagine a single line could cause so much trouble, right? So, please remember: internet security is never too much, so there is always something new to learn and to apply.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSRF and/or XSS attacks
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;Cross-Site Scripting&lt;/em&gt; (XSS) and the &lt;em&gt;Cross-Site Request Forgery&lt;/em&gt; (CSRF) attacks share some things in common, but they are not the same. Also, they can be used and implemented together.&lt;/p&gt;

&lt;p&gt;An example of this combination was the “&lt;a href="https://www.vice.com/en/article/wnjwb4/the-myspace-worm-that-changed-the-internet-forever" rel="noopener noreferrer"&gt;MySpace Worm&lt;/a&gt;” (also known as “Samy worm”, or “JS.Spacehero worm”), developed by Samy Kamkar, then a 19-year-old developer, in 2005, who created a script by adding a few words that infected some people's profiles to make him friends with, on this social network, but then quickly spread out of control, and he hit almost a million friend requests.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1623200307528%2F6mMJhlguu.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1623200307528%2F6mMJhlguu.png" alt="myspace_from_vice.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Part of Kamkar's MySpace profile showing how many friends he had after his script, on 2005. Image: &lt;a href="https://www.vice.com/en/article/wnjwb4/the-myspace-worm-that-changed-the-internet-forever" rel="noopener noreferrer"&gt;VICE&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Although its attack was ultimately harmless, a bad agent could have injected malicious code that would compromised the whole web server, if no one had noticed or taken the threat seriously.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 The &lt;em&gt;Cross-Site Request Forgery&lt;/em&gt; is also known as XSRF, as well as CSRF, following the acronym for &lt;em&gt;Cross-Site Scripting&lt;/em&gt; (XSS). The probable reason for this one is to avoid the confusion with &lt;em&gt;Cascading Style Sheets&lt;/em&gt;, used for stylize web pages, whose acronym is CSS too.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to prevent CSRF attacks
&lt;/h2&gt;

&lt;p&gt;So, how we can prevent CSRF attacks? There are some things we need to do:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Keep your web browsers up-to-date
&lt;/h3&gt;

&lt;p&gt;You'd be surprised on how many users are still using outdated web browsers and applications on their daily basis. The reasons for it are uncountable, such as the lack of information (on how to do it, and why), the compatibility with a specific version (there are many situations where the retro-compatibility doesn't exist), or even the specifications of their contracts on their companies' behalf — and I am not talking just about web browsers.&lt;/p&gt;

&lt;p&gt;As a user, the first measure to take is to keep your web browser updated to the latest version. The most used applications make use of &lt;a href="https://webkit.org/" rel="noopener noreferrer"&gt;WebKit&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Mozilla/Gecko" rel="noopener noreferrer"&gt;Gecko&lt;/a&gt;, or other browser engine, that has been currently developed and supported by the open community of developers. They are aware of these issues, and committed to solving these problems in a short term. Some of these companies behind major web browsers also have “bug bounty programs”, so they reward security researchers who can find a unique bug that may compromise user's data and privacy.&lt;/p&gt;

&lt;p&gt;If you are a developer, you should alert your users that outdated application may cause some problems, including CSRF attacks, and they may be exposing their personal data to bad agents on the internet. As a bonus, this practice helps you to deliver better user experience, as updated browsers also include new functions and APIs that enhances the usability on many websites.&lt;/p&gt;

&lt;p&gt;By the way, recently, &lt;a href="https://blog.google/products/ads-commerce/2021-01-privacy-sandbox/" rel="noopener noreferrer"&gt;Google&lt;/a&gt; and &lt;a href="https://hacks.mozilla.org/2020/08/changes-to-samesite-cookie-behavior/" rel="noopener noreferrer"&gt;Mozilla&lt;/a&gt; have announced several improvements on the security of their browsers engines, such as the “privacy sandbox”, better &lt;em&gt;HTTP Cookies&lt;/em&gt; policies, and JavaScript blocking mechanisms.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Check the HTTP Referrer header
&lt;/h3&gt;

&lt;p&gt;Most requests on modern web browser include two metadata that can help us to validate where the source is: the &lt;code&gt;Origin&lt;/code&gt; and the &lt;code&gt;Referrer&lt;/code&gt; header information.&lt;/p&gt;

&lt;p&gt;As a developer, you can check whenever a request is made to your web server if the &lt;code&gt;Origin&lt;/code&gt; and &lt;code&gt;Referrer&lt;/code&gt; header data came from the same site. If it does not, you can ignore it, and don't proceed any functions from this &lt;code&gt;Origin&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Unfortunately, there are few situations that it won't be possible, and you may potentially block legitimate requests coming from users behind a corporate &lt;em&gt;proxy&lt;/em&gt; or other similar features. Also, there are many ways to forge these headers' information, therefore many authors say it could be not the best way to protect web servers from CSRF attacks.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Implement SameSite attribute
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;SameSite&lt;/code&gt; attribute (&lt;a href="https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02" rel="noopener noreferrer"&gt;RFC6265bis&lt;/a&gt;) can really help us by mitigating CSRF attack, because an unauthorized website would not complete their request into our web server if they're using a cross-site request.&lt;/p&gt;

&lt;p&gt;In order to make our &lt;em&gt;HTTP&lt;/em&gt; Cookies restricted to the same-site location, we can implement this attribute by setting it to the &lt;em&gt;HTTP&lt;/em&gt; response header. So, our &lt;em&gt;HTTP&lt;/em&gt; Cookie can be restricted to a first-party or same-site context. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Cookie: TOKEN=1bf3dea9fbe265e40d3f9595f2239103; Path=/; SameSite=lax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;According to the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt;, the &lt;code&gt;SameSite&lt;/code&gt; attribute can accept one of three values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lax&lt;/strong&gt; — default if the &lt;code&gt;SameSite&lt;/code&gt; attribute is not specified; &lt;em&gt;HTTP Cookies&lt;/em&gt; can be sent when the user navigates to the cookie's origin site. They are not sent on normal cross-site subrequests (for example, to load images or frames into a third party site), but are sent when a user is navigating to the origin site (for example, when following a link).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;None&lt;/strong&gt; — &lt;em&gt;HTTP Cookies&lt;/em&gt; will be sent in all contexts, and can be sent on both originating and cross-site requests. This should only be used in secure contexts, like when the &lt;code&gt;Secure&lt;/code&gt; attribute is also set;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict&lt;/strong&gt; — &lt;em&gt;HTTP Cookies&lt;/em&gt; can be only to the same site as the one that originated it.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 If you're dealing with personal sensitive data, such as the ones used for users' authentication, on your web server, you should set a short lifetime for the &lt;em&gt;HTTP Cookies&lt;/em&gt;. Also, you should set the &lt;code&gt;SameSite&lt;/code&gt; attribute to &lt;code&gt;Strict&lt;/code&gt; or &lt;code&gt;Lax&lt;/code&gt;, so an unauthenticated request would not be effectively served to the web server.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Notice that you should use the &lt;code&gt;SameSite&lt;/code&gt; attribute along with an &lt;em&gt;anti-CSRF token&lt;/em&gt;, as some &lt;em&gt;HTTP Requests&lt;/em&gt;, specially the &lt;em&gt;GET&lt;/em&gt;, &lt;em&gt;HEAD&lt;/em&gt; and &lt;em&gt;POST&lt;/em&gt; methods, will be executed even if the request was not allowed, in some circumstances, and should return an &lt;em&gt;HTTP&lt;/em&gt; error code in response. Anyway, a simple request was made and &lt;a href="https://stackoverflow.com/a/67020180" rel="noopener noreferrer"&gt;executed on the server-side&lt;/a&gt;. Fortunately, there are other ways to solve this, like using along with a random value generated by a complex and secure mathematical method.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Add random tokens
&lt;/h3&gt;

&lt;p&gt;One of the most common methods of CSRF mitigation is by using an &lt;em&gt;anti-CSRF token&lt;/em&gt;, a random, secret, and unique token sent on requests to the web server. Whenever the request is made, the web server could check for this data: if they match, then it is allowed to continue with the processing; if they not, then the request can be rejected.&lt;/p&gt;

&lt;p&gt;This token can be generated for each request, stored on the web server, and then inserted on the client's request — directly on the web form, or attached to the &lt;em&gt;HTTP&lt;/em&gt; request —, so it will be possible to detect requests from unauthorized locations to our web server.&lt;/p&gt;

&lt;p&gt;The bad agents can't read the token, if used along with the &lt;code&gt;SameSite&lt;/code&gt; attribute, and they can't proceed in any function on our website if they don't have the token matching to the one the web server previously set to this specific request.&lt;/p&gt;

&lt;p&gt;This can be done by specifying an &lt;em&gt;anti-CSRF token&lt;/em&gt;, on the same site as the trustful server, and including it to a new HTML web form, like the following one:&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;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"good-form"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"http://my.trustful.bank/transfer"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&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;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"token"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"1bf3dea9fbe265e40d3f9595f2239103"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&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;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"account"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"stevie"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&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;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"amount"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"123"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/input&amp;gt;&lt;/span&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;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&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;On the client-side, we can set an &lt;em&gt;anti-CSRF token&lt;/em&gt; in PHP, like this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nv"&gt;$_SESSION&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'token'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;bin2hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;random_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 1bf3dea9fbe265e40d3f9595f2239103&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Still on the client-side, if we are using JavaScript, we can add an &lt;em&gt;anti-CSRF token&lt;/em&gt;, and send it as an &lt;em&gt;X-Header&lt;/em&gt; information on a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" rel="noopener noreferrer"&gt;XMLHttpRequest&lt;/a&gt;. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;readCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;TOKEN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;                       &lt;span class="c1"&gt;// Get the HTTP Cookie that we previously set, identified as "TOKEN"&lt;/span&gt;
&lt;span class="nx"&gt;httpRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setRequestHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-CSRF-Token&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Then, send it as an "X-CSRF-Token" header information&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next steps 🚶
&lt;/h2&gt;

&lt;p&gt;As mentioned before, internet security is never too much, so there is always something more to learn and apply. In order to build safer applications, be sure to follow the next article on this series, and read the further references to get more details about the best practices on web development.&lt;/p&gt;

&lt;p&gt;If you have any questions or suggestions on how to build more secure applications, share it in the comments. 📣&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;[1] Zeller, W., &amp;amp; Felten, E. W. (2008). Cross-site request forgeries: Exploitation and prevention. Bericht, Princeton University. &lt;a href="https://www.cs.memphis.edu/~kanyang/COMP4420/reading/csrf.pdf" rel="noopener noreferrer"&gt;https://www.cs.memphis.edu/~kanyang/COMP4420/reading/csrf.pdf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[2] Souza, J. (2009). Cross-Site Scripting &amp;amp; Cross-Site Request Forgery. Brasília, Universidade de Brasília. &lt;a href="https://cic.unb.br/~rezende/trabs/johnny.pdf" rel="noopener noreferrer"&gt;https://cic.unb.br/~rezende/trabs/johnny.pdf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[3] Seth Fogie, Jeremiah Grossman, Robert Hansen, Anton Rager, and Petko D. Petkov. XSS Attacks: Cross Site Scripting Exploits and Defense. Syngress, 2007.&lt;/p&gt;

&lt;p&gt;[4] "Cross-Site Request Forgeries and You", from &lt;em&gt;Coding Horror&lt;/em&gt;: &lt;a href="https://blog.codinghorror.com/cross-site-request-forgeries-and-you/" rel="noopener noreferrer"&gt;https://blog.codinghorror.com/cross-site-request-forgeries-and-you/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[5] "Using HTTP cookies", from &lt;em&gt;MDN Web Docs&lt;/em&gt; (Mozilla Developer Network): &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[6] "CSRF", from &lt;em&gt;MDN Web Docs&lt;/em&gt; (Mozilla Developer Network): &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/CSRF" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Glossary/CSRF&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>php</category>
    </item>
    <item>
      <title>Secure GET and POST requests using PHP</title>
      <dc:creator>Danilo César</dc:creator>
      <pubDate>Thu, 20 May 2021 18:21:22 +0000</pubDate>
      <link>https://forem.com/danilo/secure-get-and-post-requests-using-php-k50</link>
      <guid>https://forem.com/danilo/secure-get-and-post-requests-using-php-k50</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is also available in the following languages:  &lt;a href="https://medium.com/@danilocsar/requisi%C3%A7%C3%B5es-get-e-post-de-maneira-segura-usando-php-b2978af162e8" rel="noopener noreferrer"&gt;Portuguese&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;In this article, we will cover two request methods: the&lt;/em&gt; GET &lt;em&gt;and the&lt;/em&gt; POST &lt;em&gt;methods, for sending and receiving data from an HTML form using PHP. Also, we will examine the most common problems involving information security, such as&lt;/em&gt; Cross-Site Scripting (XSS) &lt;em&gt;and&lt;/em&gt; SQL Injection, &lt;em&gt;and how to solve them with adequate sanitization.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's start with the theory: what are&lt;/em&gt; GET &lt;em&gt;and&lt;/em&gt; POST &lt;em&gt;requests, and how do they differ? – if you want to, you can skip to the next section, where we will start with the practice.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Understanding the &lt;em&gt;GET&lt;/em&gt; and &lt;em&gt;POST&lt;/em&gt; methods&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;Hypertext Transfer Protocol&lt;/em&gt; (&lt;em&gt;HTTP&lt;/em&gt;) was developed as a protocol to serve the transmission of documents, and works as an intermediary between internet browsers and web servers. You are used to reading it in the addresses of web pages – as well as its “brother”, the &lt;em&gt;HTTPS&lt;/em&gt;, a more secure encrypted version (hence the “S” at the end, meaning “Secure”).&lt;/p&gt;

&lt;p&gt;In other words, &lt;em&gt;HTTP&lt;/em&gt; is a protocol that serves as a “bridge”: it collects a request from the internet browser; sends it to the server; waits for an answer; and, finally, it returns the new information to the &lt;em&gt;browser&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Generally, these requests keep some metadata in their “header”, that contains messages used to perform certain behavior on the client or on the server. In addition, &lt;em&gt;HTTP&lt;/em&gt; requests can assume different models.&lt;/p&gt;

&lt;p&gt;The most used &lt;em&gt;HTTP&lt;/em&gt; request types are &lt;em&gt;GET&lt;/em&gt; and &lt;em&gt;POST&lt;/em&gt;, but there are other types in their technical specification, such as &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;HEAD&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;, &lt;code&gt;PATCH&lt;/code&gt; and &lt;code&gt;OPTIONS&lt;/code&gt;. For the purposes of this article, we will focus only on the two most common.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The &lt;em&gt;GET&lt;/em&gt; request&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://tools.ietf.org/html/rfc7231#section-4.3.1" rel="noopener noreferrer"&gt;&lt;em&gt;GET request&lt;/em&gt; method&lt;/a&gt; is used when you want to obtain data from a specific source or resource. It should only be used to retrieval data, because its query string are sent and displayed at &lt;em&gt;URL&lt;/em&gt;, for example: &lt;code&gt;https://www.youtube.com/watch?v=fJ9rUzIMcZQ&amp;amp;t=3m5s&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When we insert this &lt;em&gt;URL&lt;/em&gt; into the &lt;em&gt;browser&lt;/em&gt;, we are asking the YouTube server for a specific resource: to retrieve the data from the video &lt;code&gt;v&lt;/code&gt; identified as &lt;code&gt;fJ9rUzIMcZQ&lt;/code&gt;. As soon as the server “returns” the request, the &lt;em&gt;HTTP&lt;/em&gt; protocol will tell the &lt;em&gt;browser&lt;/em&gt; how to display the video, in this example, the official video for the song “Bohemian Rhapsody”, by the British band Queen.&lt;/p&gt;

&lt;p&gt;Note that in our example, the second parameter of the &lt;em&gt;GET&lt;/em&gt; request, the &lt;code&gt;t&lt;/code&gt; parameter, informs the start time that we expect in our response, in this case, from 3min and 5s. The parameters &lt;code&gt;v&lt;/code&gt; and &lt;code&gt;t&lt;/code&gt; are separated by the character &lt;code&gt;&amp;amp;&lt;/code&gt;, which indicates to the &lt;em&gt;HTTP&lt;/em&gt; protocol where the “key-value” pairs of these parameters begin and end. So, the server knows exactly that you search for the video &lt;code&gt;v=fJ9rUzIMcZQ&lt;/code&gt; at the time &lt;code&gt;t=3m5s&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;GET&lt;/em&gt; requests are generally limited in length — for most &lt;em&gt;browsers&lt;/em&gt;, it is up to &lt;a href="https://stackoverflow.com/a/2659995" rel="noopener noreferrer"&gt;8 KB, or 8192 bytes&lt;/a&gt; in &lt;em&gt;URI&lt;/em&gt; — and, because they only serve to request data, they are not able to modify it. In addition, they can be stored in &lt;em&gt;cache&lt;/em&gt;, in the browser's history and also in the bookmarks. That's why you should &lt;strong&gt;never&lt;/strong&gt; use it to send sensitive data, such as Social Security Numbers and user passwords.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Some developers, however, ignore it and expose personal and sensitive data of people on the internet. In Brazil, due to the &lt;a href="http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2018/lei/l13709.htm" rel="noopener noreferrer"&gt;General Personal Data Protection Law (LGPD)&lt;/a&gt;, this practice may cause big inconveniences, such as serious penalties to the company or to the ones who operate and manage this data, when a leak happens. So, the best practice is to &lt;strong&gt;never&lt;/strong&gt; send sensitive personal data via the &lt;em&gt;GET&lt;/em&gt; method.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The &lt;em&gt;POST&lt;/em&gt; request&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://tools.ietf.org/html/rfc7231#section-4.3.3" rel="noopener noreferrer"&gt;&lt;em&gt;POST request&lt;/em&gt; method&lt;/a&gt; is used to send data to the server, to update or create a new resource.&lt;/p&gt;

&lt;p&gt;Unlike the &lt;em&gt;GET&lt;/em&gt; method, the &lt;em&gt;POST&lt;/em&gt; method does not expose the information at the &lt;em&gt;URL&lt;/em&gt; address. In this case, the data is transmitted in the &lt;em&gt;HTTP&lt;/em&gt; request body, as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /update/webform.php HTTP/1.1
Host: youtube.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 42
user=Stevie&amp;amp;playlist=British&amp;amp;v=fJ9rUzIMcZQ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we are informing the &lt;code&gt;Host: youtube.com&lt;/code&gt; server that we will make a &lt;code&gt;POST&lt;/code&gt; method request to the &lt;code&gt;/update/webform.php&lt;/code&gt; address, using the technical specifications of the &lt;code&gt;HTTP/1.1&lt;/code&gt; protocol. We are also indicating that there is a 42 character information (&lt;code&gt;Content-Length: 42&lt;/code&gt;), in the standard &lt;code&gt;Content-Type&lt;/code&gt; content format, whose value is &lt;code&gt;application/x-www-form-urlencoded&lt;/code&gt;. Finally, our information is on the bottom line, containing 3 parameters: &lt;code&gt;user&lt;/code&gt;, &lt;code&gt;playlist&lt;/code&gt;, and &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 The information traveling in the body of the &lt;em&gt;HTTP&lt;/em&gt; request can be intercepted by bad agents. The best practice, then, is to make these transmissions using encryption, via the &lt;em&gt;HTTPS&lt;/em&gt; protocol, so it makes harder to them read this information.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's assume the YouTube server recognized our request, and this address is valid. In our example, the informed video, which we received previously, will be added to the &lt;code&gt;British&lt;/code&gt; playlist of the user identified as &lt;code&gt;Stevie&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note that this is a one-time request, which is unlikely to be repeated. As a rule, the &lt;em&gt;POST&lt;/em&gt; method, unlike &lt;em&gt;GET&lt;/em&gt;, is not stored in &lt;em&gt;cache&lt;/em&gt; or in the client's browser history, nor can it be saved in bookmarks. &lt;em&gt;POST&lt;/em&gt; requests have no restrictions on the size of messages, which allows us to send complete articles, such as this one, through an electronic HTML form, for example. Also, the &lt;em&gt;POST&lt;/em&gt; method supports a wide variety of &lt;code&gt;Content-Type&lt;/code&gt;s, including binary documents, &lt;em&gt;strings&lt;/em&gt;, and numbers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;em&gt;POST&lt;/em&gt; method is generally preferable over &lt;em&gt;GET&lt;/em&gt;. However, there are situations in which we should include the requisition data in the address &lt;em&gt;URL&lt;/em&gt;: for example, in search forms or by displaying documents and videos, because we want the client to be able to repeat it easily and to re-access the address through the browser's history.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Creating forms with HTML and PHP&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that we understand how the &lt;em&gt;GET&lt;/em&gt; and &lt;em&gt;POST&lt;/em&gt; methods work in the theory, let's go to the practices: let's create an HTML form, and have it to send and to receive information using PHP.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 There are several ways to do this, like via JavaScript and &lt;em&gt;AJAX&lt;/em&gt;, where the user don't have to refresh the page, because we are transmitting the information asynchronously. For the purposes of this article, we will focus only on HTML and PHP technologies.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Inserting the form on the page&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The first step to create our web page is to inform the structure of the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element that will contain the fields where user types the data, 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="c"&gt;&amp;lt;!-- origin.html --&amp;gt;&lt;/span&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;"GET"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"webform"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"webform"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"target.php"&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;p&gt;In this fragment, we are using the &lt;em&gt;GET&lt;/em&gt; method, defined in &lt;code&gt;method="GET"&lt;/code&gt;, to send the information that will be inserted into the form, whose name was defined in &lt;code&gt;name="webform"&lt;/code&gt;, to the target page (&lt;code&gt;action="target.php"&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Inserting the fields to the form&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The next step is to insert the fields, or &lt;code&gt;input&lt;/code&gt;s to our form, where users can type the values. Let's update our source file 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="c"&gt;&amp;lt;!-- origin.html --&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&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;title&amp;gt;&lt;/span&gt;Electronic form&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;
    &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;"GET"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"webform"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"webform"&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"target.php"&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;"iduser"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;User ID:&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;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"iduser"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"iduser"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;br&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;"idplaylist"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Playlist ID:&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;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"idplaylist"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"idplaylist"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;br&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;"v"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Video ID:&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;"text"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"v"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"v"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"fJ9rUzIMcZQ"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;br&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&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;Send data&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&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;We inserted 3 fields, defined by the &lt;em&gt;HTML&lt;/em&gt; tag &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, and also 1 button that sends the form's data, using &lt;code&gt;&amp;lt;button type="submit"&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We also add labels to the text fields, using the &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; tags. Notice that each values on the &lt;code&gt;for&lt;/code&gt; attributes, on each &lt;code&gt;label&lt;/code&gt; element corresponds to an &lt;code&gt;id&lt;/code&gt; attribute of one the &lt;code&gt;input&lt;/code&gt; fields, like this: &lt;code&gt;&amp;lt;label for="idplaylist"&amp;gt;&lt;/code&gt; refers specifically to the field that contains the corresponding &lt;code&gt;id="idplaylist"&lt;/code&gt; attribute, and vice versa.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 It is possible to insert predefined values to the fields, adding the data corresponding to the &lt;code&gt;value&lt;/code&gt; attribute in each HTML &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; element.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Finally, the &lt;code&gt;name&lt;/code&gt; attribute in each &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; field will be used to obtain the values inserted by the user in the corresponding field when we move to PHP.&lt;/p&gt;

&lt;p&gt;The final result, displayed in the client's &lt;em&gt;browser&lt;/em&gt;, should look like this:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1621533203977%2FgA6-X-OJP.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1621533203977%2FgA6-X-OJP.png" alt="en_1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Reading data with PHP&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After completing our HTML form, we can move on to the next step. Let's define the elements of the target page using PHP.&lt;/p&gt;

&lt;p&gt;The source code below, inserted in the file &lt;code&gt;target.php&lt;/code&gt;, will be executed by PHP as soon as the user submits the form data that we created earlier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- target.php --&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class="c1"&gt;// Prints the values of each field on the page&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"The user identified as "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"iduser"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;" added the video whose ID is "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"v"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;" to the playlist "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"idplaylist"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"."&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that we use the &lt;em&gt;superglobal&lt;/em&gt; &lt;code&gt;$_GET[]&lt;/code&gt; variable to obtain the values inserted by the user, that were transmitted using the &lt;em&gt;HTTP&lt;/em&gt; protocol. For each &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; field that we previously created on the form, its corresponding &lt;code&gt;name&lt;/code&gt; attribute must be informed within the &lt;em&gt;superglobal variable&lt;/em&gt;. For example: the &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; field that shows the attribute &lt;code&gt;name="iduser"&lt;/code&gt; can be found in PHP by using &lt;code&gt;$_GET["iduser]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;PHP has some &lt;a href="https://www.php.net/manual/en/language.variables.superglobals.php" rel="noopener noreferrer"&gt;native &lt;em&gt;superglobals&lt;/em&gt; variables&lt;/a&gt;, such as &lt;code&gt;$_GET&lt;/code&gt;, &lt;code&gt;$_POST&lt;/code&gt;, and &lt;code&gt;$_REQUEST&lt;/code&gt;. Remember that we use them &lt;strong&gt;according to the &lt;em&gt;HTTP&lt;/em&gt; request method that we are using&lt;/strong&gt; for data transmission, so it must correspond to what been defined in the &lt;code&gt;method&lt;/code&gt; attribute of our &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 PHP's &lt;code&gt;$_REQUEST&lt;/code&gt; &lt;em&gt;superglobal&lt;/em&gt; variable can carry information from both &lt;code&gt;$_GET&lt;/code&gt; and &lt;code&gt;$_POST&lt;/code&gt; methods, in addition to any &lt;em&gt;cookies&lt;/em&gt; transmitted in &lt;code&gt;$_COOKIE&lt;/code&gt;. However, its use &lt;strong&gt;is not&lt;/strong&gt; always recommended: the best practice is that developers know the methods used for inputs and outputs traveling on their server, in order to avoid more generic commands.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then, we separate the &lt;em&gt;strings&lt;/em&gt; and the variables in PHP with the &lt;code&gt;.&lt;/code&gt; character, so each fragment of text is contained between the &lt;code&gt;"&lt;/code&gt; characters, at the beginning and at the end of the sentence. Finally, we print on the user's screen the entire expression within the parentheses with the &lt;code&gt;echo()&lt;/code&gt; function.&lt;/p&gt;

&lt;h3&gt;
  
  
  📝 Learn by doing
&lt;/h3&gt;

&lt;p&gt;Did you notice that the &lt;em&gt;URL&lt;/em&gt; address on &lt;code&gt;target.php&lt;/code&gt; page shows the values typed in the source page?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #1:&lt;/strong&gt; Rewrite the source code of the form we coded, using another requisition method, so that the information stays safe from reading by eavesdroppers and unauthorized people. After you finish, you can check &lt;a href="https://gist.github.com/DaniloCeesar/b49ec6a77f3d75380fe0b689afbfe065" rel="noopener noreferrer"&gt;the final answer&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Increasing HTML form security&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Our HTML form is finally done! However, we can increase the security of our page, protecting the reading of the information on PHP.&lt;/p&gt;

&lt;p&gt;This is our last step. We will add an extra layer of security, although basic, to prevent PHP from executing commands at the moment it receives and displays the values reported by the client.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 The rule in programming is to &lt;strong&gt;never blindly trust the values inserted by the user&lt;/strong&gt;. Unfortunately, many bad agents have exploited technical problems on websites in order to collect sensitive information, or to damage servers by executing unexpected commands. For those reasons, it is very important that you &lt;strong&gt;protect, beforehand, the transmitted requests and the server&lt;/strong&gt;, after all, if the users' interests are legitimate, they will also benefit from the increased security of your application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The technique that filters and transforms the values entered by the user into simpler &lt;em&gt;strings&lt;/em&gt; is called &lt;strong&gt;sanitization&lt;/strong&gt;. By default, PHP has a collection of native functions that helps us on this step, such as the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;htmlspecialchars()&lt;/code&gt; - Converts special characters, such as &lt;code&gt;&amp;amp;“”&amp;lt;&amp;gt;&lt;/code&gt;, to HTML entities;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;htmlentities()&lt;/code&gt; - Similar to the previous one, but it converts a larger number of characters to HTML entities;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strip_tags()&lt;/code&gt; - Removes HTML and PHP &lt;em&gt;tags&lt;/em&gt; from a &lt;em&gt;string&lt;/em&gt;, such as &lt;em&gt;hyperlinks&lt;/em&gt; and comments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we use adequate sanitization, as soon as the server receives an improper information — for example, &lt;code&gt;&amp;lt;script&amp;gt;alert('Intrusive alert');&amp;lt;/script&amp;gt;&lt;/code&gt; — it will be transformed, “sanitized”, and should not display a warning message on the users' screen in this case.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Notice that, in our example, we use a harmless, in theory, &lt;em&gt;script&lt;/em&gt; — at most, uncomfortable for the user. However, it is important to reiterate: you must &lt;strong&gt;always protect and sanitize information&lt;/strong&gt;. In other cases, a bad agent could transmit malicious &lt;em&gt;scripts&lt;/em&gt; — this technique is known as &lt;em&gt;Cross-Site Scripting&lt;/em&gt;, or &lt;em&gt;XSS&lt;/em&gt; — or execute harmful commands to the database (usually called &lt;em&gt;SQL Injection&lt;/em&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's edit the source code of our page, by adding one of these sanitizing functions. Our final code should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- target.php --&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class="c1"&gt;// Prints the values of each field on the page&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"The user identified as "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;htmlspecialchars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"iduser"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="no"&gt;ENT_QUOTES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"UTF-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;" added the video whose ID is "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;htmlspecialchars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"v"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="no"&gt;ENT_QUOTES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"UTF-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;" to the playlist "&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;htmlspecialchars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"idplaylist"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="no"&gt;ENT_QUOTES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"UTF-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"."&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final result, displayed in the browser, should look like the figure below:&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1621533214749%2F2elZdyIK4.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1621533214749%2F2elZdyIK4.png" alt="en_2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  📝 Learn by doing
&lt;/h3&gt;

&lt;p&gt;Have you ever noticed that the majority of sites and search engines use the &lt;code&gt;q&lt;/code&gt; parameter to transmit the data inserted by the user in the query requests to the server?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test #2:&lt;/strong&gt; Create a search form, using HTML and PHP, that contains at least 1 text field and 1 button to send the data, so that the address &lt;em&gt;URL&lt;/em&gt; on the target page displays the &lt;code&gt;q&lt;/code&gt; (or “query”) parameter. It should receive the values, sanitized, inserted by the user in the text field. After you finish, you can check &lt;a href="https://gist.github.com/DaniloCeesar/95c63e7c93e56deb05fb150923d03fe8" rel="noopener noreferrer"&gt;the final answer&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So, we're done! We made our electronic form in HTML that is capable of transmitting data via &lt;em&gt;HTTP&lt;/em&gt; request methods, in this case, &lt;em&gt;GET&lt;/em&gt; or &lt;em&gt;POST&lt;/em&gt; — and we also understand how they work —, and send them to the target page written in PHP. Then, it receives, handles the data, and displays the information on the user's screen. Also, we sanitized the values informed by the user in order to avoid serious problems of information security.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Next steps&lt;/strong&gt; 🚶
&lt;/h3&gt;

&lt;p&gt;Internet security it is never too much, so there is always something more to learn and apply. In order to build safer applications, be sure to follow the next article on this series, and read the &lt;a href="https://www.php.net/manual/en/security.php" rel="noopener noreferrer"&gt;Security topic in the PHP Manual&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have any questions or suggestions on how to build more secure applications using PHP, share it in the comments. 📣&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;References&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;[1] “HTTP Request Methods”, from &lt;em&gt;w3schools&lt;/em&gt;: &lt;a href="https://www.w3schools.com/tags/ref_httpmethods.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/tags/ref_httpmethods.asp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[2] “HTTP”, from &lt;em&gt;MDN Web Docs&lt;/em&gt; (&lt;em&gt;Mozilla Developer Network&lt;/em&gt;): &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[3] “GET”, from &lt;em&gt;MDN Web Docs&lt;/em&gt; (&lt;em&gt;Mozilla Developer Network&lt;/em&gt;): &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[4] “POST”, from &lt;em&gt;MDN Web Docs&lt;/em&gt; (&lt;em&gt;Mozilla Developer Network&lt;/em&gt;): &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[5] “htmlspecialchars”, from &lt;em&gt;PHP Manual&lt;/em&gt;: &lt;a href="https://www.php.net/htmlspecialchars" rel="noopener noreferrer"&gt;https://www.php.net/htmlspecialchars&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[6] “htmlentities”, from &lt;em&gt;PHP Manual&lt;/em&gt;: &lt;a href="https://www.php.net/htmlentities" rel="noopener noreferrer"&gt;https://www.php.net/htmlentities&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[7] “strip_tags”, from &lt;em&gt;PHP Manual&lt;/em&gt;: &lt;a href="https://www.php.net/strip_tags" rel="noopener noreferrer"&gt;https://www.php.net/strip_tags&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[8] “Superglobals”, from &lt;em&gt;PHP Manual&lt;/em&gt;: &lt;a href="https://www.php.net/manual/en/language.variables.superglobals.php" rel="noopener noreferrer"&gt;https://www.php.net/manual/en/language.variables.superglobals.php&lt;/a&gt;.&lt;/p&gt;

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