<?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: Troels Agergaard</title>
    <description>The latest articles on DEV Community by Troels Agergaard (@troelsagergaard).</description>
    <link>https://dev.to/troelsagergaard</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%2F214101%2F5314676a-810c-4019-a6d8-06d125779790.jpg</url>
      <title>DEV Community: Troels Agergaard</title>
      <link>https://dev.to/troelsagergaard</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/troelsagergaard"/>
    <language>en</language>
    <item>
      <title>Understanding the HTML DOM: Document Objects Model</title>
      <dc:creator>Troels Agergaard</dc:creator>
      <pubDate>Thu, 20 Feb 2025 15:23:12 +0000</pubDate>
      <link>https://dev.to/troelsagergaard/simple-introduction-to-the-dom-document-objects-and-structure-5hck</link>
      <guid>https://dev.to/troelsagergaard/simple-introduction-to-the-dom-document-objects-and-structure-5hck</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Document Object Model (DOM)&lt;/strong&gt; is a fundamental part of how web browsers interpret and manipulate HTML documents. By breaking the DOM into three main components, we can understand it as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Document&lt;/strong&gt; is the HTML file that the browser loads. This document serves as the foundation from which all elements are identified and organized.&lt;/p&gt;

&lt;p&gt;Here is an example of a simple HTML document:&lt;br&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%2Fvcza2pnvlc7388c6oxk6.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%2Fvcza2pnvlc7388c6oxk6.png" alt="The entire HTML structure makes up the document. " width="800" height="425"&gt;&lt;/a&gt;The entire HTML structure makes up the document. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Objects&lt;/strong&gt; or HTML element in the document is represented as an object in the DOM. The browser converts HTML tags into a hierarchical structure of objects, which can be manipulated using JavaScript.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; is an object.&lt;br&gt;
&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; is an object.&lt;br&gt;
&lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; is an object that contains other objects.&lt;/p&gt;

&lt;p&gt;We can access and modify these objects using JavaScript:&lt;br&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%2Fgxnn7wj13q279tdese6t.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%2Fgxnn7wj13q279tdese6t.png" alt="What is the DOM, document object model in HTML" width="800" height="164"&gt;&lt;/a&gt;This code changes the content of the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Model (Structure and Hierarchy)&lt;/strong&gt; organizes objects into a tree structure, where some elements are parents, and others are children and together, they form the model.&lt;/p&gt;

&lt;p&gt;Example of the DOM structure for the previous HTML document:&lt;br&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%2Fgvagxvxrbfdec4zknec0.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%2Fgvagxvxrbfdec4zknec0.png" alt="Image description" width="800" height="283"&gt;&lt;/a&gt;In this model, &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; is the root, &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; are child nodes, and each element within them follows the hierarchy.&lt;/p&gt;

</description>
      <category>dom</category>
      <category>html</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>A low-level entry point to get started contributing to open source.</title>
      <dc:creator>Troels Agergaard</dc:creator>
      <pubDate>Mon, 22 Feb 2021 22:35:58 +0000</pubDate>
      <link>https://dev.to/troelsagergaard/a-low-level-entry-point-to-get-started-contributing-to-open-source-2369</link>
      <guid>https://dev.to/troelsagergaard/a-low-level-entry-point-to-get-started-contributing-to-open-source-2369</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Have you ever thought that open source is only for a developer elite like Max Stoiber? And that contributing requires hours of investment?&lt;/p&gt;

&lt;p&gt;Then you are right! 😆&lt;br&gt;
Fortunately, not everyone needs to reach over twenty thousand GitHub stars on their next open-source project, like react-boilerplate did, or contribute bug fixes and improvements to complex projects like React.&lt;/p&gt;

&lt;p&gt;During Hacktoberfest 2020, I used Chrome’s Lighthouse to identify and fix small accessibility issues—such as missing &lt;code&gt;alt="Happy hacking"&lt;/code&gt; attributes on images or missing &lt;code&gt;rel="noreferrer"&lt;/code&gt; on external links. These are minor problems that impact accessibility and security.&lt;/p&gt;

&lt;p&gt;These contributions weren’t groundbreaking performance bug fixes for a framework used by millions, nor were they particularly complex or time-consuming. But they were still important and added value to the projects—something the maintainers genuinely appreciated.&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%2Fgip4i55xke4dq8d9jay9.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%2Fgip4i55xke4dq8d9jay9.png" alt="Alt Text" width="800" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’ve never contributed to an open-source project, this approach can be a great way to get started, without years of experience or hours of commitment.&lt;/p&gt;

&lt;p&gt;Happy hacking!&lt;br&gt;
Troels Agergaard&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>beginners</category>
      <category>opensource</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>How to avoid overflow behavior on translated elements</title>
      <dc:creator>Troels Agergaard</dc:creator>
      <pubDate>Sun, 21 Feb 2021 20:22:59 +0000</pubDate>
      <link>https://dev.to/troelsagergaard/how-to-avoid-overflow-behavior-on-translated-elements-422f</link>
      <guid>https://dev.to/troelsagergaard/how-to-avoid-overflow-behavior-on-translated-elements-422f</guid>
      <description>&lt;p&gt;Have you ever experienced that a CSS rule behaved differently than you would have expected it to? &lt;/p&gt;

&lt;p&gt;Last week one of my students had such a mind-twisting CSS rule! This rule translated an element, but the rendered element behaved differently than expected. It was overflowing the parent. &lt;/p&gt;

&lt;p&gt;He asked me why the element behaved like this after being translated and told me that the remaining space was defined to be distributed between the two elements by setting &lt;code&gt;justify-content: space-between;&lt;/code&gt; which worked perfectly fine before the translation. &lt;/p&gt;

&lt;p&gt;First, let's look at the transform property I said.&lt;br&gt;
By using this property, elements can be &lt;code&gt;translated: rotated, scaled, and skewed.&lt;/code&gt; But this effect will change the visual formatting model, which means that the position and shape of the affected content change. In other words, this affects the visual rendering of elements – but without disrupting the normal document flow.&lt;/p&gt;

&lt;p&gt;Let's have a look at this overflowing behavior in your project, and see if we can help get your heads around what this behavior is caused by, and then understand how to solve it. &lt;/p&gt;

&lt;p&gt;As mention earlier, everything worked as expected before translation. Rendering result before translated:&lt;br&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%2Fo5si8didhrqor4xg3j1r.jpg" 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%2Fo5si8didhrqor4xg3j1r.jpg" alt="Alt Text" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But when the elements are translated, they begin to overflow:&lt;br&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%2Fjhu9k98kak4wszswrp50.jpg" 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%2Fjhu9k98kak4wszswrp50.jpg" alt="Alt Text" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The transformation origin(Illustrated by the orange circles) is the point around which a transformation is applied. By default, the origin is center, but we can use the transform-origin CSS property to change the position of the origin. &lt;/p&gt;

&lt;p&gt;When trying to skew the justified elements, they are forced to overflow because i.e. the visual rendering of the translated element does not affect the normal document flow. &lt;/p&gt;

&lt;p&gt;Let us fix this by adjusting the origin of the left element to the upper left corner instead. For the element to the right, we change the position to the bottom right corner. &lt;/p&gt;

&lt;p&gt;This will cause the element to use these new points of the elements as the origins and therefore rotation points:&lt;br&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%2Fogjt1h35zwh67xshlg2g.jpg" 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%2Fogjt1h35zwh67xshlg2g.jpg" alt="Alt Text" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you have it, a translated element without any overflow!&lt;/p&gt;

&lt;p&gt;Happy Hacking&lt;br&gt;
Troels Agergaard&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>transform</category>
      <category>overflow</category>
    </item>
  </channel>
</rss>
