<?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>DEV Community: Mosope (Deborah) Oduwole</title>
    <description>The latest articles on DEV Community by Mosope (Deborah) Oduwole (@debtech).</description>
    <link>https://dev.to/debtech</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%2F1226914%2Fced98a00-78e5-4171-a438-68ed59305dc1.jpg</url>
      <title>DEV Community: Mosope (Deborah) Oduwole</title>
      <link>https://dev.to/debtech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/debtech"/>
    <language>en</language>
    <item>
      <title>A Comprehensive Introduction to CI/CD Pipelines</title>
      <dc:creator>Mosope (Deborah) Oduwole</dc:creator>
      <pubDate>Thu, 31 Oct 2024 21:03:00 +0000</pubDate>
      <link>https://dev.to/debtech/a-comprehensive-introduction-to-cicd-pipelines-4ijc</link>
      <guid>https://dev.to/debtech/a-comprehensive-introduction-to-cicd-pipelines-4ijc</guid>
      <description>&lt;p&gt;Introduction&lt;br&gt;
CI/CD Definition&lt;br&gt;
Concepts of CI/CD&lt;br&gt;
CI/CD Pipelines Explained&lt;br&gt;
The CI/CD Workflow&lt;br&gt;
Benefits of CI/CD Implementation&lt;br&gt;
CI/CD and DevOps&lt;br&gt;
Conclusion&lt;/p&gt;




&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Pipelines for continuous integration, delivery, and deployment are extremely useful when producing high-quality software promptly. Basically, the automation of CI/CD helps you create better code more quickly and securely. In this article, I’ll describe what CI/CD means, the CI/CD pipeline workflow, the benefits, how to implement a good CI/CD pipeline, and how CI/CD fits into the DevOps universe.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/CD Definition
&lt;/h2&gt;

&lt;p&gt;CI/CD is the acronym for the words Continuous Integration, Continuous Delivery, and Continuous Deployment which are modern development techniques that help optimize software development processes. The CI/CD process involves automatically integrating code updates from several developers into a single codebase.&lt;/p&gt;

&lt;p&gt;Using CI/CD, teams can provide updates to their code more frequently and coherently, and errors are found earlier. Thus the coding, testing, and development procedures have been streamlined thanks to CI/CD.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concepts of CI/CD
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Continuous Integration&lt;/strong&gt;: In this practice, developers will regularly commit their code changes to a common/shared repository as part of the CI development methodology. With every commit, an automatic build procedure gets triggered, and then the code gets compiled and executed in a series of automated tests to find any errors early.&lt;/p&gt;

&lt;p&gt;Each commit creates an automated workflow on a CI server and the CI server notifies developers of any issues in their code.&lt;/p&gt;

&lt;p&gt;A benefit to continuous integration is that since developers get input right away, they can fix any problems that come up immediately which helps to reduce the likelihood of code conflict.&lt;/p&gt;

&lt;p&gt;When validating your code quality in the CI process, a static code analysis helps confirm your code’s quality, and when the static tests are passed, automated CI procedures help compile the code for additional testing.&lt;/p&gt;

&lt;p&gt;Once a build passes the early static testing, it is prepared to go to more thorough testing, and the continuous integration (CI) comes to an end. If the build fails testing, the build/test cycle can be repeated until a successful build is achieved. Therefore, a continuous integration pipeline may perform code reviews, run unit tests, run builds automatically, and configure the CI pipeline to be activated whenever there is a commit/merge in your codebase.&lt;/p&gt;

&lt;p&gt;Also, CI procedures typically have a version control system that helps monitor changes. So popular CI tools like &lt;a href="https://www.jenkins.io/" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt; and &lt;a href="https://docs.gitlab.com/ee/ci/" rel="noopener noreferrer"&gt;GitlabCI&lt;/a&gt; can be integrated with version control systems like &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;Git&lt;/a&gt; to automate the CI process.&lt;/p&gt;

&lt;p&gt;The Continuous Integration Process:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F5h3nsqrfbtudx4g8dqwv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F5h3nsqrfbtudx4g8dqwv.png" alt="continuous integration process" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Continuous Delivery:&lt;/strong&gt; In the continuous delivery process, your code release is automated to a pre-production environment where you can personally test your code and validate it before it is officially deployed. During this process, code from the repository is compiled and the build is created and tested out. The software is then prepped to be ready for release automatically when it’s ready.&lt;/p&gt;

&lt;p&gt;This process helps to prevent post-production surprises by running a series of tests like load testing, UI testing, and so on which is useful in resolving defects beforehand.&lt;/p&gt;

&lt;p&gt;Continuous delivery works together with continuous integration to automate the release process of your application.&lt;/p&gt;

&lt;p&gt;The Continuous Delivery Process:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fd3yyqcp99iocsddui7eb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fd3yyqcp99iocsddui7eb.png" alt="continuous delivery process" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Continuous Deployment:&lt;/strong&gt; Here, your code changes that pass automated testing are automatically pushed to production without the need for human/manual interaction.&lt;/p&gt;

&lt;p&gt;At this stage, after the DevOps teams establish the requirements for code releases, the code is then released into the production environment once those requirements have been satisfied.&lt;/p&gt;

&lt;p&gt;The continuous deployment process is entirely automated.&lt;/p&gt;

&lt;p&gt;The entire process of continuous integration, delivery, and deployment helps businesses provide new services rapidly. For example, Amazon is constantly deploying and deploys more than 125k times daily, and according to the &lt;a href="https://cloud.google.com/resources/devops/state-of-devops" rel="noopener noreferrer"&gt;2024 State of DevOps Report&lt;/a&gt;, powerful companies with high-performing teams have the capacity to deploy multiple times daily.&lt;/p&gt;

&lt;p&gt;The continuous deployment process:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fmsxhjefmvc9lijhtznw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fmsxhjefmvc9lijhtznw2.png" alt="continuous deployment process" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/CD Pipelines Explained
&lt;/h2&gt;

&lt;p&gt;The automated process of moving your software from code commit to final production deployment is known as a CI/CD pipeline. These pipelines are the foundation of the CI/CD process and help to automatically coordinate software development, testing, and deployment processes.&lt;/p&gt;

&lt;p&gt;It is the automated DevOps workflow of continuous integration, continuous delivery, and continuous deployment as described above.&lt;/p&gt;

&lt;h2&gt;
  
  
  The CI/CD Workflow
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Faozx7zwprpmi4pahkc3v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Faozx7zwprpmi4pahkc3v.png" alt="The typical ci/cd workflow" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A CI/CD pipeline contains a series of steps/stages that make up a CI/CD workflow. These stages include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Source:&lt;/strong&gt; This is the first stage of a CI/CD pipeline process and it involves the creation of your source code. Here, source code changes can be managed using version control systems like &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;Git&lt;/a&gt;, &lt;a href="https://bitbucket.org/product/" rel="noopener noreferrer"&gt;Bitbucket&lt;/a&gt;, and so on. When change is made into your code and pushed into your repository, a CI/CD pipeline will be triggered to go into the ‘build’ stage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build&lt;/strong&gt;: Here the source code is drawn from your repository and compiled and executable/runnable artifacts (EXE files) are created. Depending on the stage of your project, the build frequency may be daily or even multiple times each day. The code is combined with dependencies and libraries to create a build that can be deployed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test&lt;/strong&gt;: A series of automated tests like integrated tests, functional tests, regression tests, and unit tests are run to validate your code, resolve any issues, and ensure your application behaves like it’s supposed to. This is one of the longer stages in your pipeline because running a series of tests can take a good amount of time.&lt;/p&gt;

&lt;p&gt;The form of testing depends on the particular project requirements.&lt;/p&gt;

&lt;p&gt;If mistakes are found during testing, the developers are notified so they can examine the results and fix them in later releases.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deployment&lt;/strong&gt;: After your code passes all required tests, it can be deployed. The tested code can be deployed to a staging or production environment/server. In continuous delivery, the code is uploaded to repositories and, after human approval, is either deployed or put into production. However, in continuous deployment, this stage is automated.&lt;/p&gt;

&lt;p&gt;Tool Options:&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fyilkm08nqhhqzw5gqoek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fyilkm08nqhhqzw5gqoek.png" alt="ci/cd pipeline tool options" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of CI/CD Implementation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;CI/CD helps you automate things that will otherwise have been done manually by developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CI/CD ensures consistency by making sure all your configurations are utilized in all environments and lowers the possibility of differences between testing and production settings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They help shorten the code commit to production time by enabling developer teams to release new features consistently. This helps promote efficient software development. This also helps free up developers’ time since it’s an automated process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CI/CD lowers the possibility of human error by eliminating the need for human interaction in repetitive processes. In this way, it detects small problems before they can grow into major disasters leading to higher code quality.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CI/CD pipelines allow developers to experiment with creative or unconventional coding techniques with significantly lower risk as opposed to the original/manual software development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It helps developers collaborate more effectively than if it were to be done manually.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They also help increase a company’s competitive edge due to fast delivery speed. As was mentioned earlier, Amazon is one of the biggest companies in the world making constant deployments multiple times daily.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CI/CD and DevOps
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F7v183tp2up6syswbwz7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7v183tp2up6syswbwz7n.png" alt="CI/CD and DevOps" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;DevOps short for Development Operations is a combination of two practices ‘Development’ and ‘Operations’, and what it is essentially is a set of practices to build, test, and release your code in small frequent steps or iterations.&lt;/p&gt;

&lt;p&gt;‘Development’ has to do with preparing your source code while ‘Operations’ has to do with deploying the source code to a specific environment. The foundation for the DevOps pipeline is CI/CD which offers the automation and dependability required for ongoing development, integration, testing, and delivery of your application.&lt;/p&gt;

&lt;p&gt;One of the core practices of DevOps is CI/CD.&lt;/p&gt;

&lt;p&gt;The typical steps of a DevOps pipeline begin with planning your application by defining the features and content of your app, then actually writing the code for the app, and then comes CI/CD through continuous integration, delivery, and deployment. After that, you can monitor your application and receive user feedback that would help in future releases.&lt;/p&gt;

&lt;p&gt;CI/CD is one of the fundamental practices of the DevOps framework.&lt;/p&gt;

&lt;p&gt;Therefore, CI/CD fits well within DevOp's objectives of enhancing teamwork, product productivity, and quality by helping close the gap between development(Dev) and operations(Ops) through the automation of dependable software releases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The lifecycle of your application can be transformed by a well-implemented CI/CD pipeline. So if you want to produce high-quality software more quickly, you should utilize the tips given in this article. Adhering to CI/CD best practices and selecting the best tools for you will help you to improve your pipeline and optimize performance.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>devops</category>
      <category>programming</category>
      <category>software</category>
    </item>
    <item>
      <title>NO PLAGIARISM</title>
      <dc:creator>Mosope (Deborah) Oduwole</dc:creator>
      <pubDate>Tue, 29 Oct 2024 13:32:37 +0000</pubDate>
      <link>https://dev.to/debtech/no-plagiarism-582h</link>
      <guid>https://dev.to/debtech/no-plagiarism-582h</guid>
      <description>&lt;p&gt;I'm not sure what's happening, but it seems my work has been plagiarized. I don't consent to my work being shared on any other platform, either translated or not. &lt;br&gt;
This person (&lt;a href="https://www.php.cn/faq/1796622875.html" rel="noopener noreferrer"&gt;https://www.php.cn/faq/1796622875.html&lt;/a&gt;) plagiarized my recent article word for word, and it seems they also publish other writers' plagiarized content.&lt;/p&gt;

&lt;p&gt;Just a heads up to my fellow writers.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Asynchronous Operations in JavaScript: The Event Loop</title>
      <dc:creator>Mosope (Deborah) Oduwole</dc:creator>
      <pubDate>Fri, 04 Oct 2024 23:43:35 +0000</pubDate>
      <link>https://dev.to/debtech/asynchronous-operations-in-javascript-the-event-loop-1179</link>
      <guid>https://dev.to/debtech/asynchronous-operations-in-javascript-the-event-loop-1179</guid>
      <description>&lt;p&gt;Introduction&lt;br&gt;
JavaScript is Synchronous by Default&lt;br&gt;
Synchronous vs Asynchronous Operations&lt;br&gt;
The Event Loop&lt;br&gt;
How it Works&lt;br&gt;
Importance of the Event Loop&lt;br&gt;
Conclusion&lt;/p&gt;


&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Picture this: you just developed a web application that has to fetch data from a server, update the user interface, and respond to all of the user actions in real-time, but you’re worried about whether your code will be able to juggle these tasks efficiently. Well, no need to worry, this is where the event loop comes in.&lt;/p&gt;

&lt;p&gt;In this article, I’ll go over how the event loop works, the differences between synchronous and asynchronous operations in JavaScript, and the importance of the event loop as a necessary non-blocking architecture.&lt;/p&gt;
&lt;h2&gt;
  
  
  Javascript is Synchronous by Default
&lt;/h2&gt;

&lt;p&gt;By default, Javascript is synchronous and code is read sequentially in order from top to bottom. Since JS is single-threaded, each task must wait for the completion of the previous one, before proceeding to the next. What this means is that each line of code is processed, one at a time, and only one operation/function is executed at any given moment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftnc213ib6cuj34zm2m5f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftnc213ib6cuj34zm2m5f.png" alt="diagram showing the synchronous nature of javascript" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, there is no way to run multiple pieces of code in parallel and any attempt to do parallelism in a language that is synchronous and single-threaded at its core is ambitious. Understanding the synchronous nature of JavaScript will help you realize how web applications respond to user interactions and handle tasks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Deb&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;                                                 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, Javascript executes the code in the order it’s written. The ‘greet’ function is called with the argument ‘Deb’. The function then returns a greeting string which is then logged to the console.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, Deb!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each line waits for the previous line to finish before executing. Therefore, the function must be completed before the result can be assigned to ‘greeting’.&lt;/p&gt;

&lt;h2&gt;
  
  
  Synchronous vs Asynchronous Operations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fbfb4di9cv0omgih79rnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fbfb4di9cv0omgih79rnr.png" alt="sync vs async image diagram" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before getting into what the event loop is, I’ll touch a little bit on what asynchronous operations are and the differences between synchronous and asynchronous operations in JavaScript. Asynchronous operations are the activities that run independently of a program flow.&lt;/p&gt;

&lt;p&gt;As stated earlier, Javascript is synchronous by default and synchronous code creates a blocking behavior where each task/function must finish before the next one starts.&lt;/p&gt;

&lt;p&gt;On the other hand, asynchronous operations do not block the execution of subsequent operations and allows javascript to attend to other tasks while waiting for the completion of that particular asynchronous task. Simply put, if you declare a function as asynchronous (async), it means the function has code that will require time to complete, and such a function will be deferred while the synchronous code runs first.&lt;/p&gt;

&lt;p&gt;Since there’s no blocking, the next synchronous code can be executed without finishing the previous async one and any async code that is ready to execute will be queued in the &lt;a href="https://redis.io/glossary/event-queue/" rel="noopener noreferrer"&gt;event queue.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Synchronous code&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Step 1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Step 2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember synchronous code is executed line-by-line. Here, JavaScript executes the statements in the order they are written.&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1
Step 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the other hand, asynchronous code allows JavaScript to continue executing while waiting for an operation to complete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Asynchronous code&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1st Function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="c1"&gt;// WEB API&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2nd Function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3rd Function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1st Function
3rd Function
2nd Function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;since the first and third functions are synchronous, they get executed first while the second function gets removed from the call stack and is handled by the web API. The web API asynchronously orders it to wait for 2000ms before being put into the event queue, which will thereafter be placed back into the empty call stack by the event loop and finally executed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Event Loop
&lt;/h2&gt;

&lt;p&gt;In its simplest definition, the event loop is a way of synchronously processing asynchronous events.&lt;/p&gt;

&lt;p&gt;In a more elaborate definition, the event loop is a continually running code loop in the Javascript runtime that allows for asynchronous operations to be executed when needed. This means it allows for JavaScript’s limiting design to handle many tasks efficiently.&lt;/p&gt;

&lt;p&gt;It spins and stays in your code background until it has specific JavaScript tasks to run. For example, clicking a button that has code associated with it from a click event handler, or when you load an external file, in cases like these, the event loop remains in the insides of the javascript runtime to execute any javascript code when needed.&lt;/p&gt;

&lt;p&gt;What all this means is that although JavaScript is single-threaded, the event loop enables JavaScript to appear to be able to run things asynchronously by offloading things to APIs and processing those events coming in when it can.&lt;/p&gt;

&lt;p&gt;Before I explain how the event loop works, there are a few specific concepts within the JavaScript runtime you need to understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Call Stack: A call stack keeps track of what functions are called and in what order to execute them. It executes synchronous code in sequential order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web APIs: These are the tools that handle asynchronous tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Callback: This is a function that is passed into another function as an argument. It helps execute code in response to an event.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event/Callback Queue: This holds tasks waiting to be executed once the call stack is clear.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How it Works
&lt;/h2&gt;

&lt;p&gt;The call stack runs synchronous code until it’s empty. When an asynchronous code is added to the call stack, it gets transferred to the API which then processes the task before it gets sent to the event queue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F0t9ejfar6g9tis5kckbz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F0t9ejfar6g9tis5kckbz.png" alt="The event loop process" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Callbacks/functions that have been completed by the API get added to the event queue and the event loop is constantly looking within the event queue to see if there is any new event/task that javascript needs to act on.&lt;/p&gt;

&lt;p&gt;Note that JavaScript can’t act on the events until the call stack is empty. Therefore, once the call stack is empty, the event loop will grab the event from the queue and place that into the call stack to be executed like other regular functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance of the Event Loop
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It keeps your code responsive while performing tasks in the background.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It helps manage your tasks effectively by monitoring the call stacks and the callback queue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides a workaround for JavaScript to perform non-blocking operations where multiple tasks can be handled concurrently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It prevents your program from going into callback hell. Callback hell happens when multiple callbacks are nested within each other making the code difficult to read or maintain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The behavior of the event loop determines when code in your application is run. The more knowledge you have surrounding the use and need for the event loop, the more you can understand why your code runs when it does.&lt;/p&gt;

&lt;p&gt;Happy coding besties!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>writing</category>
    </item>
    <item>
      <title>How to Center a DIV</title>
      <dc:creator>Mosope (Deborah) Oduwole</dc:creator>
      <pubDate>Tue, 21 May 2024 10:28:59 +0000</pubDate>
      <link>https://dev.to/debtech/how-to-center-a-div-4106</link>
      <guid>https://dev.to/debtech/how-to-center-a-div-4106</guid>
      <description>&lt;p&gt;Introduction&lt;br&gt;
Prerequisites&lt;br&gt;
The Box Model&lt;br&gt;
How to Center a Div in CSS&lt;br&gt;
How to Center a Div Horizontally&lt;br&gt;
How to Center a Div Vertically&lt;br&gt;
Centering both Horizontally and Vertically&lt;br&gt;
Comparing the Techniques&lt;br&gt;
Conclusion&lt;/p&gt;


&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;The difficulty of centering divs has to be one of the most "memeable" topics in programming. Fear not, however, gone are the days of &lt;a href="https://en.wikipedia.org/wiki/Internet_Explorer_5" rel="noopener noreferrer"&gt;IE5&lt;/a&gt;, CSS isn't tables and floats anymore, today with techniques using innovations like &lt;a href="https://www.w3schools.com/css/css3_flexbox.asp" rel="noopener noreferrer"&gt;Flexbox&lt;/a&gt;, or even CSS Grid, centering DIVs has never been easier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3schools.com/tags/tag_div.ASP" rel="noopener noreferrer"&gt;Div&lt;/a&gt;, short for content division element, defines a division in an HTML document. It is a generic block-level element that serves as a container for HTML elements, which can then be styled and manipulated with CSS and Javascript.&lt;/p&gt;

&lt;p&gt;So, how the heck do you center a div?&lt;/p&gt;

&lt;p&gt;In this article, I'll take you through the different techniques used in centering divs, from horizontal centering to vertical, centering texts, and even centering both ways simultaneously.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Preliminary knowledge of HTML&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Basic CSS knowledge&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Box Model
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F32fot3q602js6o41ilnj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F32fot3q602js6o41ilnj.png" alt="CSS Box Model" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before I get into centering techniques, I must first make sure you understand the CSS box model.&lt;/p&gt;

&lt;p&gt;Every HTML element is its own box, with its spacing and border, this is called the box model. It contains four properties, margin, border, padding and your content, which can then be styled or manipulated however you see fit.&lt;/p&gt;

&lt;p&gt;The margin property creates a margin around your selected content, and the padding property, which is a close relative of the margin creates spaces inside the edges of your div container. This means that it adds spaces &lt;strong&gt;between&lt;/strong&gt; the content and the edges of the container.&lt;/p&gt;

&lt;p&gt;Therefore, whereas margin creates space on the &lt;strong&gt;outside&lt;/strong&gt;, padding creates space on the &lt;strong&gt;inside&lt;/strong&gt; of your selected element.&lt;/p&gt;

&lt;p&gt;Finally, the border property controls the border &lt;strong&gt;between&lt;/strong&gt; the margin and the padding.&lt;/p&gt;

&lt;p&gt;What you should remember is this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Margin (Spacing on the outside)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Border (The in-between)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Padding (Spacing on the inside)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Content (The content itself)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How to Center a Div in CSS
&lt;/h2&gt;

&lt;p&gt;Understanding how to center divs and text within divs is a valuable skill for beginners and seasoned developers alike.&lt;/p&gt;

&lt;p&gt;To create visually stunning layouts, knowing how to center divs will help in arranging and styling elements on your page.&lt;/p&gt;

&lt;p&gt;Although I mentioned earlier that centering divs today has never been easier, I must admit that this task might prove surprisingly intricate and confusing due to the nuances of CSS and the various scenarios in which centering may be required.&lt;/p&gt;

&lt;p&gt;In this guide, I'll cover the various methods to center a div depending on the specific requirement of your project, and the context of your design.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to Center a Div Horizontally
&lt;/h2&gt;

&lt;p&gt;To center a div horizontally on a page, you can try the following:&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Margin: auto&lt;/strong&gt;&lt;br&gt;
Here you can leverage the &lt;code&gt;margin:auto;&lt;/code&gt; property by setting the left/right margins to auto. When centering elements horizontally using the margin property, three things must be considered:&lt;/p&gt;

&lt;p&gt;(A). &lt;strong&gt;Display should be set to block&lt;/strong&gt;: This allows for no other elements besides the current one. It takes ownership of the horizontal space of the element. However, since divs are block-level elements, this step can be omitted if your content is within a div.&lt;/p&gt;

&lt;p&gt;(B). &lt;strong&gt;Must have a width&lt;/strong&gt;: An item cannot be centered within a browser if it is wider than the browser itself. Therefore, your element must have a set width.&lt;/p&gt;

&lt;p&gt;(C). &lt;strong&gt;Margin left/right set to auto&lt;/strong&gt;: 'Auto' means 'take up all the space', and since this is a &lt;code&gt;display: block;&lt;/code&gt; element, the space would be what's left after your content has taken up the required pixels in width. The margin left/right being set to auto centers the div since they are being pushed against each other.&lt;/p&gt;

&lt;p&gt;You can also use the shorthand &lt;code&gt;margin&lt;/code&gt; property with the value &lt;code&gt;0 auto&lt;/code&gt; to center divs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="center"&amp;gt;
  &amp;lt;img src="cat.jpg" alt="cat sleeping on rug"&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;!--This is a simple code snippet showing an image of cat contained
within a div element--&amp;gt;
&amp;lt;!--This div can now be styled using css --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To center the cat image in CSS, you'll code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.center {
width: 50%;
margin: 0 auto;
}

/*Here, display:block; isn't used because the div is already a
block-level element*/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setting the margin-top to 0, and the horizontal margin to auto using the shorthand property removes the margin-top and horizontally centers the image. Therefore, the output will be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fr8vm5oqwsk2mcn66r732.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fr8vm5oqwsk2mcn66r732.png" alt="centered image of a cat sleeping on a rug" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Flexbox centering&lt;/strong&gt;&lt;br&gt;
Introduced in &lt;a href="https://www.simplilearn.com/difference-between-css-and-css3-article#:~:text=CSS3%2C%20also%20known%20as%20Cascading,more%20attractive%20and%20user%2Dfriendly." rel="noopener noreferrer"&gt;CSS3&lt;/a&gt;, Flexbox has revolutionized how we design layouts by providing a better way to arrange, align, and distribute space among items within a container.&lt;/p&gt;

&lt;p&gt;It is the most modern method to center elements on a page. To ensure that Flexbox creates the appropriate row/column you want, wrap your desired row/column in a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;A Flexbox layout always contains a container and its direct children. To use Flexbox, you need to give an element a '&lt;strong&gt;display&lt;/strong&gt;' property of '&lt;strong&gt;flex&lt;/strong&gt;'. This will make the element a '&lt;strong&gt;flex container&lt;/strong&gt;', and any direct children of a flex container are called '&lt;strong&gt;flex items&lt;/strong&gt;'.&lt;/p&gt;

&lt;p&gt;To begin create a &lt;code&gt;div&lt;/code&gt; and give it a class of container, using the above cat example create an &lt;code&gt;img&lt;/code&gt; element with &lt;code&gt;src&lt;/code&gt; and &lt;code&gt;alt&lt;/code&gt; attributes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
    &amp;lt;img src="cat.jpg" alt="cat sleeping on rug"&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
 display: flex;
 justify-content: center;
 }
 /* justify-content set to center centers the cat image */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fiytg7uajhmwi5pdo6xmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fiytg7uajhmwi5pdo6xmu.png" alt="centered image of a cat sleeping on a rug" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At its core, Flexbox takes every single item and turns it into a row or column depending on its &lt;code&gt;flex-direction&lt;/code&gt;. Note that Flexbox only turns into rows/columns "direct children" elements.&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Text Align set to Center&lt;/strong&gt;&lt;br&gt;
To center texts properly, use the &lt;code&gt;text-align&lt;/code&gt; property in CSS and give it a value of &lt;code&gt;center&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="center-text"&amp;gt;
 Centered Text
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; .center-text {
             text-align: center;
             background-color: lightblue;
             padding: 20px;
         }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output looks like this, you can see the words 'centered text' have been effectively centered on our page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxiclm9xwr4ywlf312868.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxiclm9xwr4ywlf312868.png" alt="centered text" width="800" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;CSS Grid&lt;/strong&gt;&lt;br&gt;
This is a layout grid system in CSS that allows us to create web layouts easily. Using CSS Grid you can define a grid structure and place items within the grid. This gives us total control over the alignment and positioning of our elements.&lt;/p&gt;

&lt;p&gt;Although CSS Grid is primarily used for grid-based designs, it can also be used to center elements easily.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
   &amp;lt;div class="center-grid"&amp;gt;Grid Layout Horizontal Centering.&amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
             display: grid;
             place-items: center; /* centers the child horizontally */
             background-color: pink;
             height: 100vh; /* just for this example */
         }
         .center-grid {
             background-color: lightseagreen;
             width: 50%;
             text-align: center;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fm48wd0vz1ylidqbm4l0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fm48wd0vz1ylidqbm4l0q.png" alt="centered element" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Center a Div Vertically
&lt;/h2&gt;

&lt;p&gt;To center a div vertically on a page, you can try the following:&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Using CSS Position and Transform Properties&lt;/strong&gt;&lt;br&gt;
The position property in CSS specifies the kind of positioning method used for an element on your page. It changes an element's position in your document flow, which can affect the layout of other elements on your page.&lt;/p&gt;

&lt;p&gt;On the other hand, CSS translate is a transform function that can move an element without affecting the layout of other elements on your page.&lt;/p&gt;

&lt;p&gt;Combining these two properties can help you center a div. The position property will affect the element's position on your page while the translate function will move the element from that particular position.&lt;/p&gt;

&lt;p&gt;In this case, we're going to set our &lt;code&gt;position&lt;/code&gt; property to &lt;code&gt;relative&lt;/code&gt;. An element with &lt;code&gt;position: relative;&lt;/code&gt; is positioned relative to its normal/default position. Then shift the element 50% from the top and 50% from the left to align it at the center. Now add the &lt;code&gt;transform&lt;/code&gt; property and set it to &lt;code&gt;translate&lt;/code&gt; with the value &lt;strong&gt;-50%&lt;/strong&gt; to effectively center it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="container"&amp;gt;
   &amp;lt;div class="position-transform"&amp;gt;
   Vertical Centering
 &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
   position: relative;
             height: 100vh;
             background-color: black;
 }
 .position-transform {
             position: relative;
             top: 50%;
             left: 50%;
             transform: translate(-50%, -50%);
             background-color: pink;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4rz4ahgry05t7jwyhdpv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4rz4ahgry05t7jwyhdpv.png" alt="vertically centered element" width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;CSS Grid&lt;/strong&gt;&lt;br&gt;
CSS Grid can also be used for vertical centering. All you need to do is give your element a &lt;code&gt;display&lt;/code&gt; of &lt;code&gt;grid&lt;/code&gt;, then align the item to the center.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;div class="container"&amp;gt;
   &amp;lt;div class="vertical-grid"&amp;gt;
   Vertical Centering
 &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
             display: grid;
             align-items: center;
             background-color: coral;
             height: 100vh; 
          }
 .vertical-grid {
             background-color: lightseagreen;
             width: 100%;
             }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F5rdilxckkq5azyjyud9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F5rdilxckkq5azyjyud9x.png" alt="vertically centered element" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Flexbox centering&lt;/strong&gt;&lt;br&gt;
As I mentioned above, Flexbox is a one-dimensional CSS layout that controls how items are aligned or spaced within a container. This means you can also center elements vertically using Flexbox.&lt;/p&gt;

&lt;p&gt;To begin create a container div and an additional div nested inside setting its class to 'vertical-flex'. Then in CSS, give your element a &lt;code&gt;display&lt;/code&gt; of &lt;code&gt;flex&lt;/code&gt; and align it to the center.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
     display: flex;
             align-items: center;
             background-color: grey;
             height: 100vh; 
 }
 .vertical-flex {    
   background-color: lightcoral;
             width: 50%;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fudh8v7awplax7gm7p93c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fudh8v7awplax7gm7p93c.png" alt="vertically centered element" width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Centering both Horizontally and Vertically
&lt;/h2&gt;

&lt;p&gt;1.&lt;strong&gt;CSS Grid&lt;/strong&gt;&lt;br&gt;
To center an element both ways using CSS Grid, establish grid by giving your container a display property of grid, then place your content to the center by using the &lt;code&gt;place-item&lt;/code&gt; property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
          display: grid;
             place-items: center;
             background-color: lightgray;
             height: 100vh; 
 }
 /* place-item centers your content both ways while 
 align-item only vertically centers your content*/

 .horizontal-vertical-grid {
        text-align: center;
   background-color: rgb(127,255,127);
             width: 50%;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fbqodjmofhqn4gbmyp2x6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fbqodjmofhqn4gbmyp2x6.png" alt="horizontally and vertically centered element" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Flexbox&lt;/strong&gt;&lt;br&gt;
Flexbox is versatile and can also handle both horizontal and vertical centering easily. Establish Flexbox by giving your container element a &lt;code&gt;display&lt;/code&gt; of &lt;code&gt;flex&lt;/code&gt;, justify your content by setting it to center, and align your content to the center to vertically center it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
             display: flex;
            justify-content: center;
             align-items: center;
             background-color: grey;
             height: 100vh; 
 }
 .horizontal-vertical-flex {
        text-align: center;
   background-color: orange;
             width: 50%;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Feyueopidxksfqnh42rlw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Feyueopidxksfqnh42rlw.png" alt="horizontal and vertically centered element" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Using Positioning&lt;/strong&gt;&lt;br&gt;
Combine absolute positioning with the transform function to center both ways.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
        position: relative;
             height: 100vh;
             background-color: lightgray; 
 }
 .center-absolute {
             position: absolute;
             top: 50%;
             left: 50%;
             transform: translate(-50%, -50%);
             background-color: lightpink;
             width: 50%;
             text-align: center;
         }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Frlmqz57lpr601ix7but3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Frlmqz57lpr601ix7but3.png" alt="vertical and horizontally centered element" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing the Techniques
&lt;/h2&gt;

&lt;p&gt;Each centering technique has its pros and cons, depending on the specific requirements of your design and your personal preference.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Margin: auto;&lt;/code&gt; requires less code and is simple to implement, it is perfect for horizontally centering elements with a fixed width. Flexbox gives you control over the alignment of your elements with properties like &lt;code&gt;align-items&lt;/code&gt; and &lt;code&gt;justify-content&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;CSS Grid being two-dimensional takes things a step further by providing control over both rows and columns at the same time. Positioning is flexible and can be used to center elements regardless of their dimensions or the container's dimensions.&lt;/p&gt;

&lt;p&gt;Flexbox and CSS Grid are probably the most versatile methods for centering, as they are modern and suitable for most responsive design needs. A good understanding of the strengths and limitations of each approach will help you make informed decisions when centering.&lt;/p&gt;

&lt;p&gt;Coding is a skill, and like all skills, centering divs require some practice. As renowned author Norman Vincent Peale stated:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nobody ever mastered any skill except through intensive persistent and intelligent practice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Remember, keep practising and soon you'll be centering divs like a master developer!&lt;/p&gt;

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

&lt;p&gt;From basic CSS properties to more advanced methods, I have covered various ways you can center a div. Understanding the box model principle and exploring the various centering techniques will help you create visually appealing layouts and user-friendly interfaces.&lt;/p&gt;

&lt;p&gt;Happy coding besties!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>writing</category>
      <category>programming</category>
      <category>css</category>
    </item>
    <item>
      <title>Exploring Some Features of HTML5</title>
      <dc:creator>Mosope (Deborah) Oduwole</dc:creator>
      <pubDate>Sun, 12 May 2024 18:21:11 +0000</pubDate>
      <link>https://dev.to/debtech/exploring-some-features-of-html5-1md2</link>
      <guid>https://dev.to/debtech/exploring-some-features-of-html5-1md2</guid>
      <description>&lt;p&gt;Table of contents&lt;br&gt;
Introduction&lt;br&gt;
What is HTML5?&lt;br&gt;
Some Features of HTML5&lt;br&gt;
HTML vs HTML5&lt;br&gt;
How to Create HTML5 Files&lt;br&gt;
HTML5 Looking Forward&lt;/p&gt;


&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;HTML has come a long way since its establishment in 1989 and has since served as the core language of the World Wide Web. From static and simple webpages to dynamic web applications, the web is constantly changing and the introduction of HTML5 represents a significant leap in the world of web development.&lt;/p&gt;

&lt;p&gt;This article aims to explore the key features of HTML5, from the &lt;a href="https://www.w3schools.com/html/html5_semantic_elements.asp" rel="noopener noreferrer"&gt;semantic elements&lt;/a&gt; to its multimedia features, HTML5 has helped restructure how the internet is accessed.&lt;/p&gt;

&lt;p&gt;The primary focus of this article is on the 5th version of HTML, so if you want to learn more about the concept of HTML itself, go &lt;a href="https://dev.to/debtech/a-comprehensive-guide-to-html-for-beginners-pbl"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is HTML5?
&lt;/h2&gt;

&lt;p&gt;Introduced on the 22nd of January 2008 with goals such as improving the language by adding the latest multimedia support, and keeping the language(HTML) readable and consistently understood by both humans and devices, it aimed to solve the problems of a new era.&lt;/p&gt;

&lt;p&gt;A sequel to &lt;a href="https://www.w3.org/TR/html401/intro/intro.html#h-2.3" rel="noopener noreferrer"&gt;HTML4&lt;/a&gt;, HTML5 is the latest specification of the HTML language. It is a &lt;a href="https://en.wikipedia.org/wiki/Markup_language" rel="noopener noreferrer"&gt;markup language&lt;/a&gt; used for structuring and presenting &lt;a href="https://en.wikipedia.org/wiki/Hypertext" rel="noopener noreferrer"&gt;hypertext&lt;/a&gt; documents on the web.&lt;/p&gt;

&lt;p&gt;It was finally released as a World Wide Web Consortium (W3C) recommendation in 2014.&lt;/p&gt;

&lt;p&gt;HTML5 created a shift in web development and offers features that enable developers to create interactive and dynamic web applications and the ultimate user experience for visitors.&lt;/p&gt;
&lt;h2&gt;
  
  
  Some Features of HTML5
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fuviibgye1mkchhy6m1bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fuviibgye1mkchhy6m1bi.png" alt="woman sipping tea while working on laptop" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Features introduced to HTML by HTML5 include:&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Semantic Elements&lt;/strong&gt;: This is the foundation of modern web development. Semantic elements like &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; tags and more were introduced by HTML5. These elements help to provide structure and clarity to an HTML document and help in code readability.&lt;/p&gt;

&lt;p&gt;Using certain elements helps the browser know how to display your code. For example, the &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt; element tells the browser that the content in &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt; should be loaded first.&lt;/p&gt;

&lt;p&gt;On the other hand, a &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; element tells the browser that the content in &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; should be loaded last.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;header&amp;gt;
   &amp;lt;h1&amp;gt;My first header element&amp;lt;/h1&amp;gt;
 &amp;lt;/header&amp;gt;
 &amp;lt;section&amp;gt;
   &amp;lt;h2&amp;gt;My first section element&amp;lt;/h2&amp;gt;
   &amp;lt;p&amp;gt;your content&amp;lt;/p&amp;gt;
 &amp;lt;!--Before adding any new content, the section element can be
 used to separate existing content from future content --&amp;gt;
 &amp;lt;/section&amp;gt;
 &amp;lt;footer&amp;gt;
   &amp;lt;p&amp;gt;All rights reserved&amp;lt;/p&amp;gt;
   &amp;lt;!--The footer element can contain copyright information,
 back-to-top links, and so on --&amp;gt;
   &amp;lt;!--It is a structural element used to identify the footer
 of a page, document, article or section --&amp;gt;
 &amp;lt;/footer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code block depicts some semantic elements with content they may contain.&lt;/p&gt;

&lt;p&gt;What should be remembered is that semantic elements are those elements that accurately reflect the content they contain and are helpful for code readability and leveraging search engine optimization &lt;a href="https://en.wikipedia.org/wiki/Search_engine_optimization" rel="noopener noreferrer"&gt;(SEO)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Figure and Figcaption&lt;/strong&gt;: HTML5 allows you to use &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt; elements to mark up and define photos. The &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; element represents "self-contained" content and allows you to associate an image with a caption.&lt;/p&gt;

&lt;p&gt;As for &lt;code&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt;, it allows you to add a caption to a particular content nested within a &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; element. For image elements, the &lt;code&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt; is placed just above the closing tag of the &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt;, after the image&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Thus to add a caption to an image of a cat, you can code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;figure&amp;gt;
   &amp;lt;img src="cat.jpg" alt="cat sleeping on tree"&amp;gt;
   &amp;lt;figcaption&amp;gt; What breed of cat do you have?&amp;lt;/figcaption&amp;gt;
 &amp;lt;/figure&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fcgy4ij1prk60oogagxhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fcgy4ij1prk60oogagxhu.png" alt="cat sleeping on a tree" width="597" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Form Enhancements&lt;/strong&gt;: HTML5 introduces new input types for the existing &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element in HTML. For example (&lt;code&gt;&amp;lt;input type="email"&amp;gt;&lt;/code&gt;,&lt;code&gt;&amp;lt;input type="password"&amp;gt;&lt;/code&gt;), and validation attributes like ('required', 'minlength', 'maxlength') which help to streamline form development for the best user experience.&lt;/p&gt;

&lt;p&gt;Validation attributes are special attributes that can be added to form elements to provide validation rules and constraints for user input. These attributes improve user experience by providing instant feedback on input errors.&lt;/p&gt;

&lt;p&gt;This means that if the data entered by the user/visitor does not meet specific criteria, it will not be submitted to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;input type="password" minlength="8"&amp;gt;

 &amp;lt;!--By adding a 'minlength' validation attribute with a value of '8',
  it tells the browser that the user must type
  in not less than 8 characters when setting their password--&amp;gt;

 &amp;lt;input type="password" pattern="[a-z0-5]{8,}"&amp;gt;

 &amp;lt;!--The pattern attribute defines an expression that the
 password must match to be considered valid--&amp;gt;
 &amp;lt;!-- This particular value means that the user can input 8 
 or more lowercase alphabets, or the digits 0-5 --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These enhancements simplify data input and facilitate user input validation, without relying on javascript.&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;Multimedia Additions&lt;/strong&gt;: Multimedia support with the use of &lt;code&gt;&amp;lt;audio&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; elements allow the integration of audio and video files on your website, and the dynamic rendering of graphics directly within your browser using a scripting language(Javascript, PHP, and so on).&lt;/p&gt;

&lt;p&gt;Unlike the former iterations, HTML5 does away with the reliance on third-party plugins like &lt;strong&gt;Adobe Flash&lt;/strong&gt; for multimedia content, improving performance and simplifying multimedia integration.&lt;/p&gt;

&lt;p&gt;5.&lt;strong&gt;Application Programming Interfaces(API)&lt;/strong&gt;: HTML5 introduced a range of APIs that help developers create more interactive web applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Geolocation API&lt;/strong&gt; allows websites to access the user's/visitor's geographical location, and in turn, enables location-based services. Here, the user sends their longitude and latitude and this data is sent to the backend server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The data can then be used to create fancy applications like fitness tracking apps, transportation apps, and so on. However, the geographical position of a user is not accessed unless they approve of it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Drag and Drop API&lt;/strong&gt; simplifies the implementation of the drag-and-drop functionality. In HTML, any element can be dragged and dropped. It allows you to drag any element in the &lt;a href="https://en.wikipedia.org/wiki/Document_Object_Model#:~:text=A%20Document%20Object%20Model%20(DOM,text%20content%20of%20the%20document)" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; and drop it to another location.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In HTML, apart from the default behaviour for images, links, and selections, no other elements are draggable by default. To make other HTML elements draggable, provide a "&lt;strong&gt;draggable&lt;/strong&gt;" attribute for the element you wish to make draggable and set its value to "&lt;strong&gt;true&lt;/strong&gt;", then add a listener for the '&lt;strong&gt;dragstart&lt;/strong&gt;' event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="dragElement" draggable="true"&amp;gt;Drag me!&amp;lt;/div&amp;gt;
    &amp;lt;div id="dropzone"&amp;gt;Drop here!&amp;lt;/div&amp;gt;

    &amp;lt;script&amp;gt;
      const dragElement = document.getElementById('dragElement');
      const dropzone = document.getElementById('dropzone');

      dragElement.addEventListener('dragstart', function(e) {
        e.dataTransfer.setData('text/plain', 'Dragged text');
      });

      dropzone.addEventListener('dragover', function(e) {
        e.preventDefault();
      });

      dropzone.addEventListener('drop', function(e) {
        e.preventDefault();
        const data = e.dataTransfer.getData('text/plain');
        dropzone.innerHTML = `Dropped text: ${data}`;
      });
    &amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a simple drop zone area where you can drag and drop files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The WebStorage API&lt;/strong&gt; provides for easy storage of data on the client's device. This feature helps to reduce transactions between the application and the backend server, to create a fast application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The WebSocket API&lt;/strong&gt; facilitates real-time communication between clients and servers, unlike the previous versions where the server responds &lt;em&gt;after&lt;/em&gt; the client sends a request.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The introduction of these features among many others enables developers to unlock the full potential of the web, providing usefulness to HTML pages and contributing to more dynamic web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML vs HTML5
&lt;/h2&gt;

&lt;p&gt;The latest iteration of HTML, HTML5, builds upon HTML while introducing several new features, as listed above.&lt;/p&gt;

&lt;p&gt;Other than the fact that HTML5 is simply the current version of the markup language, reasons such as it being easier to write, and maintain, better for accessibility and SEO, makes it superior.&lt;/p&gt;

&lt;p&gt;You should note that HTML5 is not a replacement for HTML but rather an improvement. However, using outdated HTML versions is not preferred.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Create HTML5 Files
&lt;/h2&gt;

&lt;p&gt;If you're reading this, I assume you already know how to create HTML documents as the language basics are the same. However, if you don't know how to create a standard HTML5 document, refer to my previous article &lt;a href="https://dev.to/debtech/a-comprehensive-guide-to-html-for-beginners-pbl"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can find it under the subheading "&lt;a href="https://dev.to/debtech/a-comprehensive-guide-to-html-for-beginners-pbl#creating-your-first-html-file"&gt;Creating Your First HTML File&lt;/a&gt;".&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;HTML5 Looking Forward&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Certain features of HTML5 have been covered in this article, from utilising semantic elements to making responsive web images using HTML5. In addition to modernizing web development, these features give HTML pages more strength and dynamism.&lt;/p&gt;

&lt;p&gt;By adhering to best practices for writing clean and maintainable code, developers can leverage the full potential of the web.&lt;/p&gt;

&lt;p&gt;Happy coding besties!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>writing</category>
      <category>html</category>
      <category>programming</category>
    </item>
    <item>
      <title>A Comprehensive Guide to HTML for Beginners</title>
      <dc:creator>Mosope (Deborah) Oduwole</dc:creator>
      <pubDate>Sat, 27 Apr 2024 18:32:51 +0000</pubDate>
      <link>https://dev.to/debtech/a-comprehensive-guide-to-html-for-beginners-pbl</link>
      <guid>https://dev.to/debtech/a-comprehensive-guide-to-html-for-beginners-pbl</guid>
      <description>&lt;p&gt;Table of contents&lt;br&gt;
Introduction&lt;br&gt;
What Exactly is HTML?&lt;br&gt;
How to Write HTML&lt;br&gt;
 . HTML Document Structure&lt;br&gt;
 . Anatomy of an HTML Element&lt;br&gt;
Common HTML Tags&lt;br&gt;
Common HTML Attributes&lt;br&gt;
Creating Your First HTML File&lt;br&gt;
Resources for Further Learning&lt;br&gt;
Conclusion&lt;/p&gt;


&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;As you begin your developer journey, understanding HTML is crucial as it helps you create a website's basic foundation. HTML was created to support linking among online resources and this served as a revolutionary step in building the web as we know it.&lt;/p&gt;

&lt;p&gt;In the context of web development, however, HTML has to do with the contents of a website, think of it as a skeleton that provides the backbone and structure to webpages. A solid understanding of HTML helps you build functional websites which can then be styled by &lt;a href="https://www.w3schools.com/css/" rel="noopener noreferrer"&gt;CSS&lt;/a&gt; and manipulated by &lt;a href="https://www.w3schools.com/whatis/whatis_js.asp" rel="noopener noreferrer"&gt;JavaScript&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As of 2024, over 95% of websites use HTML.&lt;/p&gt;

&lt;p&gt;This article will serve as a comprehensive guide to HTML, walking you through its fundamental concepts, how HTML is written, common tags and attributes, the creation of an HTML file along with common text editors for coding HTML, and finally provide you with further resources for learning HTML.&lt;/p&gt;
&lt;h2&gt;
  
  
  What Exactly is HTML?
&lt;/h2&gt;

&lt;p&gt;Created by &lt;a href="https://en.wikipedia.org/wiki/Tim_Berners-Lee" rel="noopener noreferrer"&gt;Tim Berners-Lee&lt;/a&gt; in 1989, HTML serves as the core language of the World Wide Web. HTML, an acronym for HyperText Markup Language, is the backbone of the web allowing users to navigate using hyperlinks across different websites.&lt;/p&gt;

&lt;p&gt;As a markup language, HTML marks up the page with annotations within the HTML file. These annotations are not rendered on the browser but work behind the scenes in telling the browser how to display content to the general public.&lt;/p&gt;

&lt;p&gt;When building a house, a good foundation must be set up to ensure it is structurally sound. In the same way, HTML is the foundation upon which websites are built, providing the structure and semantics for presenting content on the web.&lt;/p&gt;

&lt;p&gt;Before we continue, note that HTML is majorly not considered a programming language but rather a markup language. It has been argued that since HTML serves a structural purpose, not a functional one, it cannot be considered a programming language.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to Write HTML
&lt;/h2&gt;

&lt;p&gt;HTML documents follow a standard structure consisting of elements which tell the browser what to render.&lt;/p&gt;

&lt;p&gt;A basic HTML element contains a starting and closing tag, and content, and could contain attributes and values.&lt;/p&gt;

&lt;p&gt;Like humans, a proper HTML structure has a &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and a &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;. The &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element is where you add the &lt;a href="https://www.w3schools.com/tags/tag_meta.asp" rel="noopener noreferrer"&gt;metadata&lt;/a&gt; while the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; contains information that will be displayed on the webpage. You should only place in your &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag what will be displayed on the page, then indent everything else inside the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML Document Structure
&lt;/h2&gt;

&lt;p&gt;A basic HTML structure looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
  &amp;lt;!-- This is where you insert the metadata --&amp;gt;
  &amp;lt;!-- The metadata contains information about your webpage --&amp;gt;
  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
   &amp;lt;!-- The body contains visible content within your webpage --&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/code&gt;&lt;/strong&gt;: This is the first line of code in HTML. It specifies the HTML version, is known as a declaration and ensures the browser tries to meet industry-wide specifications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;html lang="en"&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/strong&gt;: These are the opening and closing tags for the HTML document, it contains a 'lang' attribute which is added to the opening  tag with the value 'en' to specify that the language of the page is in English.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;/code&gt;&lt;/strong&gt;: This contains metadata about the page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt;&lt;/strong&gt;: This contains the title of the page that will be displayed in the browser's title bar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&lt;/code&gt;&lt;/strong&gt;: Contains visible content on the webpage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anatomy of an HTML Element
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F9sywljlpqh1y3oykkgmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F9sywljlpqh1y3oykkgmf.png" alt="Diagram showing the basic HTML structure" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Various HTML elements help convey information to a web browser, from the diagram above you can see HTML elements are designated by tags (an opening and a closing tag) *note that some elements do not require a closing tag.&lt;/p&gt;

&lt;p&gt;The attribute provides additional information to an element while the value provides additional information to your added attribute. Take an &lt;em&gt;anchor&lt;/em&gt; element 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;&amp;lt;a href="link adress"&amp;gt; your content &amp;lt;/a&amp;gt;

&amp;lt;!--The opening &amp;lt;a&amp;gt; depicts the opening tag--&amp;gt;
&amp;lt;!--href is the attribute depicting the hypertext reference for your
anchor tag--&amp;gt;
&amp;lt;!--The link address is the value--&amp;gt;
&amp;lt;!--The closing &amp;lt;/a&amp;gt; depicts the end tag--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common HTML Tags
&lt;/h2&gt;

&lt;p&gt;In total over 142 HTML tags exist, each serving its purpose at different levels within the HTML document. I have curated the essential elements you will most likely come across when coding HTML.&lt;/p&gt;

&lt;p&gt;Most HTML elements have an opening and a closing tag.&lt;/p&gt;

&lt;p&gt;The opening tag contains the element enclosed by angle brackets(&amp;lt;&amp;gt;). On the other hand, the closing tag(where applicable) contains the element enclosed by angle brackets along with a forward slash preceding the element name (&amp;lt;/&amp;gt;).&lt;/p&gt;

&lt;p&gt;Essential HTML tags include:&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Headings(H1 - H6&lt;/strong&gt;): Headings define the hierarchy of contents on a webpage and it ranges from &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; being the most important to &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt; being the least important. Adding a lower-rank heading element to your document implies that you are starting a new subsection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt; &amp;lt;!-- Most important heading --&amp;gt;
 &amp;lt;h6&amp;gt;hello world&amp;lt;/h6&amp;gt; &amp;lt;!-- sub-heading --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Paragraphs(p)&lt;/strong&gt;: This lets you add a paragraph to your webpage, paragraphs are useful in presenting a structured document.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;This is your paragraph content&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;Links(a)&lt;/strong&gt;: As shown earlier, the anchor element creates hyperlinks which help you navigate between web pages, or even within sections on the same page.&lt;/p&gt;

&lt;p&gt;To ensure your link opens in a new tab, you can add the keyword (target="_blank").&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;Images(img)&lt;/strong&gt;: Images can be added to an HTML document using the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag. Unlike the tags you have seen so far, the image tag is self-closing, which means it does not require a closing tag.&lt;/p&gt;

&lt;p&gt;For image elements, it is essential to have a (src) attribute specifying the image source. It also helps to have an (alt) attribute to improve accessibility for screen readers if your image fails to load.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src="blah.jpg" alt="blah doing blah" /&amp;gt;
 &amp;lt;!-- alt attributes also help your site rank higher on google search
 pages since it provides important metadata about the image --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.&lt;strong&gt;Divisions(div)&lt;/strong&gt;: &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags are generic block-level container elements used to group and style similar content. This tag does not affect the content of your document unless styled with CSS or manipulated with JavaScript.&lt;/p&gt;

&lt;p&gt;It is commonly said that an HTML document is a collection of divs. Other tags can be nested within a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element, and even divs can be nested within other divs. This is known as the 'HTML document tree'.&lt;/p&gt;

&lt;p&gt;Here is a diagram I created showcasing the HTML document tree and how elements are nested inside each other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F64t6q03vhq1o7sg1qslo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F64t6q03vhq1o7sg1qslo.png" alt="Diagram showcasing the HTML document tree" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6.&lt;strong&gt;Lists(ul)(ol)(li)&lt;/strong&gt;: Lists can either be ordered(ol) or unordered(ul). To create an ordered list, code the opening &lt;code&gt;&amp;lt;ol&amp;gt;&lt;/code&gt; tag along with the closing &lt;code&gt;&amp;lt;/ol&amp;gt;&lt;/code&gt;. Inside this, nest the list item tags &lt;code&gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;/code&gt;, then indent everything.&lt;/p&gt;

&lt;p&gt;The same goes for creating bullet points, all you have to do is nest your list items (li) in an unordered list element.&lt;/p&gt;

&lt;p&gt;Therefore to create a bullet point of grocery items, you should code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul&amp;gt;
   &amp;lt;li&amp;gt;Eggs&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Butter&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Flour&amp;lt;/li&amp;gt;
   &amp;lt;li&amp;gt;Sugar&amp;lt;/li&amp;gt;
 &amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fjfbliud7g2cxfvcjvda8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fjfbliud7g2cxfvcjvda8.png" alt="Rendered unordered list code" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that you have learnt some common HTML tags, let us move on to the common HTML attributes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common HTML Attributes
&lt;/h2&gt;

&lt;p&gt;HTML attributes provide extra information about the element that will not appear in the content.&lt;/p&gt;

&lt;p&gt;They are always specified in the start/opening tag of the element and are usually assigned a value. name/value are attribute pairs. (name="value"). Note that attribute values must be enclosed in quotation marks.&lt;/p&gt;

&lt;p&gt;You should also remember that not all HTML elements require an attribute, and not all attributes require a value(these are called &lt;a href="https://meiert.com/en/blog/boolean-attributes-of-html/" rel="noopener noreferrer"&gt;Boolean attributes&lt;/a&gt;). Don't stress, as you get further into learning HTML, these concepts become easier to understand.&lt;/p&gt;

&lt;p&gt;Common HTML attributes include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The (src) attribute&lt;/strong&gt;: The source attribute (src) is useful in an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element with the corresponding value being the image link. If a (src) attribute is not added to an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element, the browser will not know what image to render.&lt;br&gt;
&lt;code&gt;&amp;lt;img src="image link"/&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The (href) attribute&lt;/strong&gt;: Defines the destination of hyperlinks on an HTML document and the value specifies the link's destination. If a (href) attribute is not added to an anchor&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element, the visitor will not be sent anywhere by the browser when the link is clicked.&lt;br&gt;
&lt;code&gt;&amp;lt;a href="your link"&amp;gt;link text&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The (class) and (id) attributes&lt;/strong&gt;: These provide extra information and styling to HTML elements by utilising CSS for styling and JavaScript for manipulation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The (lang) attribute&lt;/strong&gt;: An essential attribute that must be added to the start tag of your &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; element. It specifies the language of the web page and helps to assist browsers and search engines. Setting your &lt;code&gt;&amp;lt;html lang="en"&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt; specifies that the language of the page is in English.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The (alt) attribute&lt;/strong&gt;: This is not an essential attribute but adding an (alt) to your &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element is considered good HTML practice. Adding an alternative text makes your site accessible to those who might need it (for example, visitors with low vision) and acts as a fallback if your image fails to render properly (perhaps due to a spelling mistake or something else). It is also considered good SEO practice. &lt;code&gt;&amp;lt;img src="cat.jpg" alt="cat sleeping on rug" /&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are more attributes and learning how to leverage them effectively will help enhance your HTML document. What should be remembered is that HTML attributes are special words used inside an HTML element to control the element's behaviour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Your First HTML File
&lt;/h2&gt;

&lt;p&gt;To begin using HTML, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Download a Text Editor&lt;/strong&gt;: A Text Editor is any form of a computer program that helps you change, edit, create and open text files. Basically, it helps you write code. There are several text editors for coding HTML. Some of my favourites are &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;Visual Studio Code&lt;/a&gt;, &lt;a href="https://notepad-plus-plus.org/downloads/" rel="noopener noreferrer"&gt;Notepad++&lt;/a&gt;(Windows), &lt;a href="https://www.sublimetext.com/" rel="noopener noreferrer"&gt;Sublime Text&lt;/a&gt;(Mac), and many others.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After downloading the text editor, you will see an editor window after it is opened. Here, you will code your first line of HTML.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Begin with a &lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/code&gt; which acts as a declaration for your page, followed by a &lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt; element setting the (lang) to English. &lt;code&gt;&amp;lt;html lang="en"&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Within your &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; element nest a &lt;code&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&lt;/code&gt; elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element nest a &lt;code&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/code&gt; element setting the content to '&lt;strong&gt;My first HTML page&lt;/strong&gt;' to give your page a title.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nest a &lt;code&gt;&amp;lt;h1&amp;gt;&amp;lt;/h1&amp;gt;&lt;/code&gt; element and a &lt;code&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/code&gt; element within your &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; setting the contents to "&lt;strong&gt;My first Heading&lt;/strong&gt;" for the former and "&lt;strong&gt;My first paragraph&lt;/strong&gt;" for the latter.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
 &amp;lt;html lang="en"&amp;gt;
   &amp;lt;head&amp;gt;
     &amp;lt;title&amp;gt;My first HTML page&amp;lt;/title&amp;gt;
   &amp;lt;/head&amp;gt;
   &amp;lt;body&amp;gt;
     &amp;lt;h1&amp;gt;My first Heading&amp;lt;/h1&amp;gt;
     &amp;lt;p&amp;gt;My first paragraph&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;7.Next, save the file you just created on your computer and assign it a (.html) extension.&lt;/p&gt;

&lt;p&gt;8.To view your completed file, open it by double-clicking on the saved file. This will make it open in your default browser. You should see your web page displayed according to the HTML files you added.&lt;/p&gt;

&lt;p&gt;9.Congratulations bestie! You just created your first HTML file, I'm so proud of you!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fy9wj7l3sr3niylg134xh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fy9wj7l3sr3niylg134xh.png" alt="gif of me being a proud code mama" width="500" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10.As you can see, it is a pretty basic page so you are free to play around with it. You can edit the file in your text editor by adding more HTML elements with images, forms, links and other elements for a more dynamic web page. Don't forget to save the changes to see them reflected in your browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources for Further Learning
&lt;/h2&gt;

&lt;p&gt;To continue your journey in mastering HTML, here are some valuable resources that helped in my developer journey:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.freecodecamp.org/learn/2022/responsive-web-design/" rel="noopener noreferrer"&gt;&lt;strong&gt;freeCodeCamp&lt;/strong&gt;&lt;/a&gt;: The 'Responsive Web Design' course on free code camp helped to jumpstart my developing career. As the name implies it's free and only requires you to create an account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=a_iQb1lnAEQ&amp;amp;t=13585s" rel="noopener noreferrer"&gt;&lt;strong&gt;HTML and CSS by Per Borgen&lt;/strong&gt;&lt;/a&gt;: This is a video I always recommend to absolute beginners. Per did an amazing job simplifying the concepts and engaging the listener.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.theodinproject.com/paths/foundations/courses/foundations" rel="noopener noreferrer"&gt;&lt;strong&gt;The Odin Project&lt;/strong&gt;&lt;/a&gt;: A hands-on introduction to computer basics, HTML, CSS, and Flexbox, among others.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Whether you prefer online tutorials or recommended books, there is no shortage of avenues to learn HTML, you should do your research and choose the resource that works best for you!&lt;/p&gt;

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

&lt;p&gt;HTML is the language of the web and as you embark on your developer journey, a good understanding of HTML will prove useful and rewarding in the digital landscape.&lt;/p&gt;

&lt;p&gt;You can always build simple websites with HTML alone but note that to build beautiful and functional websites, a good understanding of CSS and JavaScript will be essential in the future. Like humans, HTML can be likened to the skeleton, CSS to the skin and JavaScript to the brains of a website.&lt;/p&gt;

&lt;p&gt;Remember that practice and perseverance are key in whatever you wish to learn and HTML is just the beginning of an exciting adventure in creating dynamic and interactive web experiences. I wish you good luck in your developer journey.&lt;/p&gt;

&lt;p&gt;Happy coding besties!&lt;/p&gt;

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