<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Frederic Aerts on Medium]]></title>
        <description><![CDATA[Stories by Frederic Aerts on Medium]]></description>
        <link>https://medium.com/@frederic-aerts?source=rss-659cdb6e22ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0lUpGmouKxR21UthV62UmA.jpeg</url>
            <title>Stories by Frederic Aerts on Medium</title>
            <link>https://medium.com/@frederic-aerts?source=rss-659cdb6e22ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 01:04:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@frederic-aerts/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Petanque World | The original French throwing game]]></title>
            <link>https://medium.com/outdoor-throwing-games-publications/petanque-world-the-original-french-throwing-game-80afbf77de96?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/80afbf77de96</guid>
            <category><![CDATA[france]]></category>
            <category><![CDATA[outdoor-games]]></category>
            <category><![CDATA[petanque]]></category>
            <category><![CDATA[pétanque]]></category>
            <category><![CDATA[family-fun]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Mon, 03 Jan 2022 17:19:03 GMT</pubDate>
            <atom:updated>2022-01-03T19:40:30.464Z</atom:updated>
            <content:encoded><![CDATA[<h3>Petanque | The original French throwing game</h3><figure><img alt="3 petanque balls and a jack" src="https://cdn-images-1.medium.com/max/600/1*Q1toYwUIcZLQTQLQIRoAKA@2x.jpeg" /></figure><p>Petanque (French pronunciation: [petɑ̃k]) is a throwing game with characteristics similar to games like bowling, <a href="https://www.molkky.world/molkky-game">Mölkky</a> and <a href="https://www.kubb.world/the-game">kubb</a>. Petanque falls into the category of <em>boules</em> sports, where players throw their balls (i.e. boules) towards a target ball. The word <em>petanque</em> is derived from the expression <em>pè tancat</em> in the Provençal dialect of the Occitan language, meaning <em>feet anchored</em>. The <strong>objective of the game</strong> is to score points by having balls closer to a small target ball than the opponent after all balls have been thrown.</p><p>Everyone can enjoy petanque. It takes only a few minutes to grasp and requires little equipment and infrastructure. The game is normally played on hard dirt or gravel, but can also be played on grass, sand or other surfaces. Petanque is played by <strong>two teams</strong>, where each team consists of one, two, or three players. Playing a game of petanque requires both skill and precision, but also a strategical mindset!</p><p>Boules games have a very long history, dating back to ancient Greece. Petanque in its current form was invented in 1907 in La Ciotat near Marseille. It gained widespread popularity after World War II.</p><h3>A Brief History</h3><figure><img alt="Vase painting of a woman juggling in Ancient Greece" src="https://cdn-images-1.medium.com/max/152/0*OWebUwRthMiCLLEn.jpg" /><figcaption><em>source: ancientolympics.arts.kuleuven.be</em></figcaption></figure><p>As early as the 6th century BC, the <strong>Ancient Greeks</strong> were playing games of tossing coins, then flat stones, and later stone balls — trying to have them go as far as possible. The <strong>Ancient Romans</strong> modified the game by adding a target to throw at, thereby making it more of a game of skill. After the Romans, the stone balls were replaced by wooden balls. Throughout the <strong>Middle Ages</strong>, the popularity of ball games periodically waned. But in certain regions such as Provence in France, it remained popular.</p><p>In the second half of the 19th century, a form of <em>jeu de boules</em> known as <strong>jeu provençal</strong> became extremely popular in France. In this game, players had to run three steps before throwing a ball. In 1907 in La Ciotat (near Marseille), this rule was adapted for the sake of an old rheumatic man (Jules Lenoir), who could no longer make this run. According to the new rules, the pitcher had to stay in place, which was enforced by drawing a circle around him. They called the game <strong>pieds tanqués</strong>, <em>feet anchored</em>, a name that eventually evolved into the game’s current name, petanque. Petanque quickly became the most popular form of <em>jeu de boules</em>.</p><p>Initially, petanque balls were made from wood. To give these wooden balls more weight, they were usually covered with metal nails. After World War I, cannonball manufacturing technology was adapted to create <strong>metal balls</strong>. Nowadays, petanque balls are manufactured by stamping two steel blanks into hemispheres, which are then welded together to create the hollow metal petanque balls we are familiar with today.</p><h3>A Global Success</h3><p>After booming in the South of France at the start of the 20th century, petanque has now become a global success. From World War II onwards, petanque began an impressive advance that at first engulfed all of France, and soon included other countries from <strong>Europe and beyond</strong>. The many tourists that discovered petanque in France began to import it into their own regions. Petanque is also played in the former French colonies like Laos, Thailand, Vietnam, Cambodia, India and some parts of Africa. <a href="https://www.petanque.world/tournaments"><strong>Petanque tournaments</strong></a> are played all over the world.</p><p><a href="https://www.petanque.world/associations"><strong>Petanque associations</strong></a> exist not only in France, but also in Belgium, Germany, Switzerland, Spain, as well as in the US, Canada and other countries. The <a href="https://fipjp.org/index.php/en">Fédération Internationale de Petanque et Jeu Provençal</a> (FIPJP) saw the light of day in 1958. In 1959, they organized the first petanque <strong>World Championship</strong>. Today, FIPJP has about 600.000 members in 52 countries and counting.</p><p>Petanque is not yet an <strong>Olympic sport</strong>. With the purpose of lobbying the Olympic committee, the <em>Confédération Mondiale des Sports de Balls</em> (CMSB) was created. Ever since 1985, the CMSB continues to represent its application to make petanque part of the summer Olympics.</p><h3>Game Rules</h3><figure><img alt="Image of a person measuring the points at the end of a round of petanque" src="https://cdn-images-1.medium.com/max/325/0*CRoItrjoa7pMOY69.jpeg" /></figure><p>Petanque is played between <strong>two teams</strong>. The objective is to score points by having balls closer to a small target ball — <em>the jack</em> — than the opponent. The ball nearest to the jack is said to be <strong>holding the point</strong>. The team that is not <em>holding the point</em> throw their balls until they place a ball closer to the jack, thereby triggering the other team to throw their balls until they are again <em>holding the point</em>, etc… A round of petanque ends when both teams have thrown all their balls.</p><p>The team whose best ball is closest to the jack at the end of the round, wins the round. They get <strong>one point for each ball</strong> that is closer to the jack than the losing team’s best ball. A game of petanque is played over multiple rounds. The <strong>winner</strong> is the first team to reach <strong>13 points</strong>.</p><h3>Petanque Tournaments</h3><figure><img alt="Semifinal of the Mondial la Marseillaise à Petanque in 2006." src="https://cdn-images-1.medium.com/max/600/0*IW10nKa3cu4N7kaj.jpg" /></figure><p>The <em>FIPJP world championships</em> and the <em>Masters de Petanque</em>, the <em>Europetanque</em> and the <em>British Open Petanque Championships</em>. Year in year out, a great many petanque tournaments are played all over the world. For professional players in associations, or laid-back players with no further aspirations. There are tournaments organized to suit everyone’s taste, so don’t be afraid to sign up for a tournament near you.</p><h3>International Championships</h3><p>In 1959, the FIPJP organized the first petanque <strong>World Championship</strong>. And ever since 1971, they’ve been organizing this event yearly without interruption. <em>Men’s</em> championships are held in even-numbered years, while <em>Women’s and Youth</em> championships are held in odd-numbered years. Over the years, France has proven to be the best performing country by far.</p><p>The <strong>European Petanque Championships</strong>, also called <em>Europetanque</em>, is organized by the <a href="https://www.cep-petanque.com/">Confédération Européenne de Petanque</a> (CEP) and the federations of its member countries. There are competitions for five player groups: <em>Youth</em> (under 18), <em>Up-and-coming</em> (Espoirs, under 23), <em>Women</em>, <em>Men</em>, and <em>Veteran</em> (over 55).</p><p>The <strong>Petanque Masters</strong> is another international competition, contested by teams in triplets. It takes place throughout the summer in eight stages, across eight French towns. It’s one of the toughest petanque championships in the world.</p><h3>National Championships</h3><p>Petanque is enormously popular in France, and therefore most of the tournament action is taking place over there. The <a href="https://www.mondiallamarseillaiseapetanque.com/"><strong>Mondial la Marseillaise à Petanque</strong></a> is the largest petanque competition in the world. Open to all, it brings together more than 13.000 players and 150.000 spectators every year in Marseille.</p><p>The largest annual tournament in the United States is the <strong>Petanque Amelia Island Open</strong> (formerly the Petanque America Open), held in November at Amelia Island, Florida. The <strong>British Open</strong> is a major Petanque tournament in the North of England which attracts players from across the United Kingdom and Europe. Needless to say, many other petanque tournaments are taking place all over the world.</p><p><em>Originally published at </em><a href="https://www.petanque.world/the-game"><em>https://www.petanque.world</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80afbf77de96" width="1" height="1" alt=""><hr><p><a href="https://medium.com/outdoor-throwing-games-publications/petanque-world-the-original-french-throwing-game-80afbf77de96">Petanque World | The original French throwing game</a> was originally published in <a href="https://medium.com/outdoor-throwing-games-publications">outdoor-throwing-games</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubb | The original Swedish throwing game]]></title>
            <link>https://medium.com/outdoor-throwing-games-publications/kubb-world-the-original-swedish-throwing-game-830d6a1588a2?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/830d6a1588a2</guid>
            <category><![CDATA[sweden]]></category>
            <category><![CDATA[outdoor-games]]></category>
            <category><![CDATA[kubb]]></category>
            <category><![CDATA[family-fun]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Wed, 02 Jun 2021 12:27:15 GMT</pubDate>
            <atom:updated>2021-06-02T12:40:00.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Picture of a kubb set" src="https://cdn-images-1.medium.com/max/354/1*OcKGinrzvGSUmFKXUtjt8w@2x.png" /></figure><p>Kubb (Swedish pronunciation: [kɵbː]) is a Swedish game with characteristics similar to games like bowling, <a href="https://www.molkky.world/molkky-game">Mölkky</a> and pétanque. The word <em>kubb</em> stems from the term <em>vedkubbar</em>, which means <em>wooden block</em> in the Gotland dialect of Swedish. Kubb is played between two teams. <strong>The objective of the game</strong> is to knock over all the <em>kubbs</em>, and then the king, with throwing sticks — before the opposing team does.</p><p>Everyone can enjoy kubb. It takes only a few minutes to grasp and can be played on different surfaces, such as grass, sand, snow or even ice. The <strong>number of players</strong> can vary, although 8 to 16 players is generally recommended. The <strong>duration of a game</strong> can range from 30 seconds to more than an hour. Playing a game of kubb requires both skill and precision, but also a strategical mindset!</p><p>The game kubb has a long history. Kubb as we know it today was invented on a Swedish island named Gotland. It gained widespread popularity in the late 1980s, when commercial sets were first manufactured.</p><h4>A Brief History</h4><figure><img alt="Predecessor of the game kubb in Ancient Egypt" src="https://cdn-images-1.medium.com/max/160/0*GyOCr24C95bvNkr_.png" /><figcaption><em>Source: Same Old Games, [</em><a href="https://creativecommons.org/licenses/by-sa/4.0"><em>CC BY-SA 4.0</em></a><em>], via Wikimedia Commons</em></figcaption></figure><p><strong>Gotland</strong> — Sweden’s largest island — is generally considered the home and origin of the game kubb. Legend has it that the game dates back to the <strong>Vikings</strong> and has survived since then on Gotland, but there’s really no evidence to support this. Kubb is sometimes marketed as <em>Viking Chess</em> nonetheless. There is however evidence that skittle games similar to kubb were played in Ancient Egypt (see image) and Greece, which leads us to conclude they migrated north, rather than the other way around.</p><p>Because of the <a href="http://runeberg.org/nfbo/0293.html">description of a skittles war game</a> similar to kubb in the second edition of the Swedish Encyclopedia <em>Nordisk familjebok</em>, 1911 is often considered the year of birth for kubb. The <strong>first written mention</strong> of the word <em>kubb</em> however is dated to 1931 in a book by a Gotland native ethnologist, visiting the island Fårö. Since Fårö is part of the province Gotland, one could say that kubb was invented on Gotland after all.</p><p>In Gotland in the late 1980s, kubb’s popularity suddenly surged as it started to emerge in parks and gardens. There came a demand, and so the first kubb sets for <strong>commercial sales</strong> were made. In 1995, the first Kubb World Championship was organised in Rone, Gotland. By 1998, kubb had become so popular that it became interesting for the Swedish company <a href="https://www.brio.us/">Brio</a> to produce cheap factory made sets — targeted at the international market. Nowadays, most kubb sets are made of rubberwood, which does not easily chip or splinter.</p><h4>A Global Success</h4><p>After booming in the Nordic countries in the late 1990s, kubb has now become a global success. <a href="https://www.kubb.world/associations"><strong>Kubb associations</strong></a> exist not only in Sweden, but also in countries like England, Germany, Netherlands, France, as well as in the US and Canada. <a href="https://www.kubb.world/tournaments"><strong>Kubb tournaments</strong></a> are played all over the world. Belgium alone hosts more than 50 tournaments each year. And the <strong>Kubb World Championship</strong>? It’s still organised on the island of Gotland — a 3 day event that attracts more than 3000 participants every year.</p><p>The slogan of the Kubb World Championship — <strong><em>Kubb unites people and creates peace on Earth</em></strong> — perfectly conveys the philosophy of the game kubb. A game to be enjoyed by family and friends and a game to serve as a spirited competition, but never mean spirited. A good outdoor game brings people together in the fresh air and spurs conversation and camaraderie. Kubb fits the bill. If you haven’t played, give it a try!</p><h3>Game Rules</h3><figure><img alt="Visualisation of a kubb set as you might find it in the midst of a game" src="https://cdn-images-1.medium.com/max/325/0*dP9Rw_8CQDZmfOMm.png" /></figure><p>Kubb is played between <strong>two teams</strong>. Team A uses batons to try to — from behind their <em>baseline</em> — knock over the <em>base kubbs</em> on team B’s side of the pitch. Kubbs that are knocked over by team A are then thrown back, by team B, onto team A’s half of the pitch. Team B then throws the batons at team A’s kubbs, first knocking over any standing <em>field kubbs</em>. The kubb closest to the <em>middle line</em> of the field represents the <em>throwing line</em> for the attacking team.</p><p>The first team to knock over all the kubbs, and subsequently <strong>the king</strong>, wins the game. A team that accidentally knocks over the king during the game, immediately loses the game.</p><p><a href="https://www.kubb.world/game-rules">Read more about the game rules</a></p><h3>Kubb Tournaments</h3><figure><img alt="Kubb king on an unused pitch during final rounds of the 2013 USA Kubb National Championship." src="https://cdn-images-1.medium.com/max/600/0*Y7ylvawORWd7qQt8.jpg" /><figcaption><em>Source: Jamie Thingelstad, [</em><a href="https://creativecommons.org/licenses/by-sa/3.0"><em>CC BY-SA 3.0</em></a><em>], via Wikimedia Commons</em></figcaption></figure><p>The Kubb World Championship and the <em>Kubb It Up</em>, the European Championships and the U.S. Kubb Open. Year in year out, a great many kubb tournaments are played all over the world. For professional players in associations, or laid-back players with no further aspirations. There are tournaments organized to suit everyone’s taste, so don’t be afraid to sign up for a tournament near you.</p><h4>International Championships</h4><p>Since 1995, the <a href="https://www.kubbvm.com/en/">official Kubb World Championship</a> has been held annually in Rone on the Swedish island of Gotland. The Kubb World Championship is open to all kubb teams who register, there are no age restrictions. In the first year of the Kubb World Championships, 28 teams showed up — most of them from Gotland. Today, the three day event attracts <strong>3–4000 visitors</strong>, who are served by up to a hundred local voluntary officials. Teams not only from Sweden, but also from countries such as Great Britain, Austria, Germany, France and Australia are taking part.</p><p>The <a href="https://kubb-em.hpage.com/Kubb_EM-3BasisInfoEngl.html">official Kubb European Championship</a> (Kubb EM) of the <em>European Kubb Federation</em> has been taking place in Berlin every year since 2011 at the end of July. The <strong>Kubb EM</strong> is an open championship for all European teams of three or more people. In parallel, the associations from Germany, Belgium and Switzerland founded the <a href="http://www.kubbeurope.com/">European Kubb Championship</a> under the direction of the <em>European Kubb Association</em> (EKA).</p><h4>National Championships</h4><p>Kubb is most popular in Europe. European tournaments are held in Sweden, Germany, Switzerland, Belgium, the Netherlands, Great Britain and many more. Most countries have their own national championship tournament. Some of the more notable local tournaments are the <strong>Kubb It Up</strong> in Switzerland, <strong>Dresdner Frühjahrsmeisterschaft</strong> in Germany and the <strong>KubbHW</strong> in the Netherlands.</p><p>Kubb is gaining in popularity on other continents as well. Tournaments in the U.S. have exploded since 2007, especially in the Midwest. Also on the Asian and Australian continents, kubb is no longer a rarity.</p><p><em>Originally published at </em><a href="https://www.kubb.world/the-game"><em>https://www.kubb.world</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=830d6a1588a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/outdoor-throwing-games-publications/kubb-world-the-original-swedish-throwing-game-830d6a1588a2">Kubb | The original Swedish throwing game</a> was originally published in <a href="https://medium.com/outdoor-throwing-games-publications">outdoor-throwing-games</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An accountable video platform for kids]]></title>
            <link>https://medium.com/tinytarantino/an-accountable-video-platform-for-kids-d99b9e4ff03c?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/d99b9e4ff03c</guid>
            <category><![CDATA[accountability]]></category>
            <category><![CDATA[kids]]></category>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[youtube-kids]]></category>
            <category><![CDATA[video-platforms]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Mon, 28 Sep 2020 08:13:59 GMT</pubDate>
            <atom:updated>2023-11-27T08:54:00.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*x1JgtjTcdyNy-2G9.png" /></figure><h3>It’s not uncommon for parents to let their children watch videos when they have to get something done. Digital videoplatforms like YouTube and Vimeo offer lots of high-quality videos that are suitable for kids. The problem is that these videos are not the ones that are favored by the recommendation algorithms at work.</h3><p>Where the traditional television shows are losing more and more viewers, digital videoplatforms are growing all over the world and on every screen. Kids can tap their way across a digital ecosystem populated by countless videos. There are many high-quality videos to be found. Unfortunately, they usually don’t surface.</p><p>What we see is that many of the most popular videos targeted at kids have an amateur feel to them. Kids go nuts over <a href="https://www.youtube.com/results?search_query=finger+family">Finger Family videos</a> and toy demonstrations like the <a href="https://www.youtube.com/results?search_query=surprise+egg">Surprise Egg videos</a>. Millions and millions of these nonsensical videos receive billions and billions of views, but it’s unlikely that children are learning from them.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgKaI4SVt7TE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgKaI4SVt7TE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgKaI4SVt7TE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/468c92392044e709cbc1cbcd9452c9b0/href">https://medium.com/media/468c92392044e709cbc1cbcd9452c9b0/href</a></iframe><p>What really seems to be driving this <a href="https://www.ted.com/talks/james_bridle_the_nightmare_videos_of_children_s_youtube_and_what_s_wrong_with_the_internet_today?language=en">disturbing evolution</a> most fully on YouTube, is the monetization of attention — without any other variables at work. The same mechanisms that Facebook and Instagram uses to get you to keep checking that app, are now used to hack the brains of very small children in return for advertising revenue.</p><p>The available content is not curated, but rather filtered by algorithms. As a result, we see that the creators of YouTube Kids videos spend countless hours trying to game the algorithm so that their videos are viewed as many times as possible — more views translate into more advertising dollars for them. And on the other side of the screen, there still are these little kids watching this stuff, stuck, their full attention grabbed by these weird mechanisms.</p><p>At <a href="https://tinytarantino.fredericaerts.com/">Tiny Tarantino</a>, we do things differently. We believe that the decision on what videos are appropriate for our kids shouldn’t be left up to unaccountable systems. We are offering an alternative where every available video is hand-picked by either you or us. An aggregation platform where the best videos from around the web are gathered. A web application that will enable parents to create qualitative video playlists for their kids to watch.</p><p><em>Originally published at </em><a href="https://tinytarantino.fredericaerts.com/"><em>https://tinytarantino.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d99b9e4ff03c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinytarantino/an-accountable-video-platform-for-kids-d99b9e4ff03c">An accountable video platform for kids</a> was originally published in <a href="https://medium.com/tinytarantino">TinyTarantino</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mölkky | The original Finnish throwing game]]></title>
            <link>https://medium.com/outdoor-throwing-games-publications/m%C3%B6lkky-the-original-finnish-throwing-game-16fc41381fed?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/16fc41381fed</guid>
            <category><![CDATA[outdoors]]></category>
            <category><![CDATA[wood]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[finnish]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Mon, 25 May 2020 14:07:17 GMT</pubDate>
            <atom:updated>2021-06-02T12:25:28.154Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mölkky is a Finnish throwing game that was invented in 1996 by the company Lahden Paikka. It is a game that requires both skill and precision, but also a strategical mindset!</h4><figure><img alt="Picture of a Mölkky set" src="https://cdn-images-1.medium.com/max/500/1*bBp56ofyViYyP3yW7Ql5qQ.jpeg" /></figure><p><a href="https://www.lahdenpaikka.fi/">Lahden Paikka</a> has been manufacturing Mölkky since the 90’s. The production of the game is eco‐friendly because the company uses excess wood from other projects. There are no nasty chemicals involved. Plus, the natural timber is sourced from 100% sustainable Finnish forests. In 2015, Mölkky actually won the <strong>Green Toy of the Year Award</strong>!</p><p>Given the exotic name of the game, Mölkky (Finnish: [ˈmølkːy]) is commonly misspelled as <em>molky</em>, <em>mollky</em>, <em>molkki</em> or <em>molki</em>. The word <em>mölkky</em> was coined by its creators and has no actual meaning. It was probably inspired by the Finnish word <em>pölkky</em>, which means <em>block of wood</em>.</p><h3>A Brief History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*6bS0YJzMrYTepGwE.jpg" /><figcaption><em>source: </em><a href="http://www.finlit.fi/en"><em>Finnish Literature Society</em></a></figcaption></figure><p>Mölkky is based on a game that has been played for centuries, called <strong>Kyykkä</strong> — also know as Finnish or Karelian Skittles. It was originally played in Karelia, a region that covers parts of Russia and Finland. In the 20th century, a great number of Karelians migrated to Finland to escape civil war. And luckily, they brought Kyykkä with them!</p><p>The rules of Kyykkä can vary quite a bit, but it basically goes like this: the players throw a <em>karttus</em> (a club resembling a baseball bat) at <em>kyykkäs</em> (small cylindrical skittles) to knock them out of their own game square. The team who needs the fewest throws wins. Traditionally, the winners would get to ride on the backs of the losing team!</p><p>Mölkky is sort of a “light” version of Kyykkä. You’re not required to throw a huge and heavy <em>karttus</em> bat, so Mölkky is suitable for anyone. Even for the most serious couch potatoes.</p><h3>A Global Success</h3><p>Today, <a href="https://www.molkky.world/tournaments"><strong>Mölkky tournaments</strong></a> are played all over the world. There is also a <strong>Mölkky World Championship</strong> (with around 200 teams of 4 to 6 players participating) organized every year. <a href="https://www.molkky.world/associations"><strong>Mölkky associations</strong></a> exist not only in Finland but also in many other countries such as Slovakia, Turkey and even Japan! Since 2006, the game has become a huge success in <strong>France</strong> in particular. France is now the leading country (before Finland) where Mölkky is sold and played the most.</p><p>In August 2016, the <a href="https://www.international-molkky.org/">International Mölkky Organisation</a> (I.M.O.) was founded. This organisation serves at the intersection between countries, associations, administrators, players, and official tournaments. Its aim is to provide safe, fair, and enjoyable competitive experiences for associations, teams and players.</p><p>While some companies sell their own branded version of the game (such as <a href="http://www.finska.com.au/">Finska</a> or <a href="https://klop.com.au/">Klop</a>), the Mölkky trademark is now owned by the Finnish board game company <a href="http://tactic.net/">Tactic Games</a>.</p><p>So yes, the global Mölkky force is strong. Passionate Mölkky players work hard to promote the game around the world. There’s even a possibility to become <strong>“Mölkky Nobility”</strong>: that’s how the former <em>Finnish International Mölkky Organization</em> (FIMO) recognized people’s contributions to the cause. Wouldn’t it be nice to become a lord or lady of Mölkky?</p><h3>Game Rules</h3><p>The players use a throwing pin (<strong>the Mölkky</strong>) to try to knock over wooden pins, which are marked with numbers from 1 to 12. Knocking over one pin scores the amount of points that is marked on the respective pin. Knocking over two or more pins scores the number of pins that were knocked over. After each throw, the pins are stood up again in the exact location where they landed.</p><p>The first one to reach <strong>exactly 50 points</strong> wins the game. If a player scores more than 50 points, the player’s score is set back to 25 points. A player that misses all of the target pins three times in a row is eliminated from the game.</p><p><a href="https://www.molkky.world/molkky-rules">Read more about the game rules</a></p><h3>Mölkky Tournaments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7tQI1LeT1P57fX08.jpg" /></figure><p>The World Cup, the Nations Trophy, the French Open and the Individual Masters. Year in year out, a great many Mölkky tournaments are played all over the globe. For professional players in associations, or laid-back players with no further aspirations. There are tournaments organized to suit everyone’s taste, so don’t be afraid to sign up for a tournament near you.</p><h3>International Championships</h3><p>From 1996 until 2015, the <strong>World Championships</strong> were organized every year in Lahti, Finland. Due to the growing popularity of Mölkky worldwide however, Finland is nowadays no longer guaranteed as the host for this magnificent tournament. Indeed, the 2016 World Championship was the first in the series that took place outside of Finland, namely in Rheu (near Rennes), France.</p><p>In 2014, the 1st Indoor <strong>European Championship</strong> was held in Tallinn, Estonia. And just like the Davis Cup in tennis, there is also a <strong>Nations Trophy</strong> for Mölkky. Regardless of the global popularity of the game, Finland is still superior in this area.</p><h3>National Championships</h3><p>Mölkky is enormously popular in France, and therefore most of the tournament action is taking place over there. Open to all, and with more than 500 teams participating, the <strong>Open de France</strong> is the biggest yearly recurring tournament in France to date. Since 2013, a French <strong>Inter-Club</strong> championship is also being organized, where official Mölkky associations (on invitation) battle for honour and glory.</p><p>Mölkky is gaining in popularity outside of France as well, giving rise to tournaments like the <strong>Austrian Open</strong>, <strong>Deutsche Meisterschaft</strong>, <strong>Japan Open</strong>, <strong>Spanish National Championship</strong>, <strong>Mexican Open</strong> and many more alike …</p><p><em>Originally published at </em><a href="https://www.molkky.world/molkky-game"><em>https://www.molkky.world</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16fc41381fed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/outdoor-throwing-games-publications/m%C3%B6lkky-the-original-finnish-throwing-game-16fc41381fed">Mölkky | The original Finnish throwing game</a> was originally published in <a href="https://medium.com/outdoor-throwing-games-publications">outdoor-throwing-games</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 3: Behavior and going live]]></title>
            <link>https://frederic-aerts.medium.com/day-3-behavior-and-going-live-5d8d4a73afba?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d8d4a73afba</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 10:44:19 GMT</pubDate>
            <atom:updated>2020-11-26T01:54:05.622Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJtkfHoT_b9_jDs1x3A_2A.jpeg" /></figure><p><em>“How to become a web developer in 3 days” is a beginner-friendly series designed to help aspiring web developers get acquainted with the languages that make up a website.</em></p><p><strong><em>Explore the series:</em></strong></p><ul><li><a href="https://medium.com/@frederic_aerts/day-1-what-websites-are-made-of-2f572662db71"><em>Day 1: What websites are made of</em></a></li><li><a href="https://medium.com/@frederic_aerts/day-2-structure-and-styling-2576c63f0258"><em>Day 2: Structure and styling</em></a></li></ul><h3>Day 3: Behavior (JavaScript) and going live</h3><blockquote><em>Action may not always bring happiness, but there is no happiness without action.</em></blockquote><blockquote><em>— Benjamin Disraeli</em></blockquote><p><strong>In the last 2 days you’ve acquired some decent web development skills, and a stunning website to back it up. Today, you’ll learn how to share this website on the World Wide Web. But if you think that sharing a website with a broken tab navigation is kind of embarrassing, then you’d better dig into this JavaScript crash course starting… right now!</strong></p><h3>JavaScript crash course</h3><p>Yesterday we created an empty JavaScript file (script.js) in our workspace. We also wired this file into our website by referencing it in the &lt;head&gt; tag of our &quot;index.html&quot; file. This JavaScript file will eventually house the code that brings the tabs on your website to life. But for now, let’s use it as a laboratory for getting familiar with the language. The goal here is to get familiar enough with JavaScript to get them tabs working, no more and no less. Let’s start from the beginning. A JavaScript program is just a set of instructions that tell the computer what tasks to perform. Like most programming languages, JavaScript often needs to track values as they change over the course of a program. JavaScript has the ability to do so by storing values in so-called <strong>variables</strong>. Let’s create such a variable and output its value via the window.alert() method.</p><p><em>In your “script.js” file, add the following JavaScript statements:</em></p><pre>var myVariable = &#39;Hello&#39;;<br>window.alert(myVariable);</pre><p>When you refresh your web page, a pop-up box is displayed with the contents of the variable named myVariable.</p><p>So in this code snippet, we assigned the value &quot;Hello&quot; to the aptly named variable myVariable. The names of variables are of your choosing. When you express values in a program, you choose different representations for those values based on what you plan to do with them. These different value representations are called <strong>types</strong>. When you need to do math, you want a number. When you need to make a conditional decision in your program, you need a boolean (either true or false). In our example, we stored a sequence of characters in our variable. This type of value is called a string, which by convention gets surrounded by double or single quotes.</p><p>A special type of values are <strong>functions</strong>. A function is a named section of code that can be called to run repeatedly, and thus enables us to break up our code into reusable pieces. Consider for instance the personalization of our greeting message to several persons, like so:</p><pre>var myVariable = &#39;Hello&#39;;</pre><pre>var greetingTom = myVariable + &#39; Tom&#39;;<br>window.alert(greetingTom);</pre><pre>var greetingSara = myVariable + &#39; Sara&#39;;<br>window.alert(greetingSara);</pre><pre>var greetingBob = myVariable + &#39; Bob&#39;;<br>window.alert(greetingBob);</pre><p>Note the space character before each person’s name, ensuring the concatenated values are displayed in the pop-up as two separate words.</p><p>In order to personalize our greeting message, we have to repeat the same two steps over and over; concatenation of each person’s name to the myVariable variable and passing this concatenated variable to the window.alert() method. And for every new person we want to greet, we’ll have to repeatedly repeat this repetition. These two steps for creating a personalized greeting message are thus a perfect candidate for a reusable function. Here’s how:</p><p><em>In your “script.js” file, add some greeting functionality, like so:</em></p><pre>var myVariable = &#39;Hello&#39;;</pre><pre>var greetFunction = function(name) {<br> var greeting = myVariable + &#39; &#39; + name;<br> window.alert(greeting);<br>}</pre><pre>greetFunction(&#39;Tom&#39;);<br>greetFunction(&#39;Sara&#39;);<br>greetFunction(&#39;Bob&#39;);</pre><p>Note that we can invoke functions by attaching round brackets to them. We can optionally pass in a value or variable (argument) in between these brackets, like we did here with the person’s name. This passed-in argument is then accessible in the function as a so-called parameter, name in our example.</p><p>The benefits are immediately obvious. Every new person we need to greet now requires only one line of code instead of two. We’ve actually abstracted the greeting logic away into a separate function, leaving us with more readable and maintainable code. If the function would have more processing logic (and thus more statements) in it, the benefits would be even more pronounced.</p><p><strong>Arrays</strong> are another type of built in JavaScript tools. An Array is a JavaScript type that can hold multiple values. Most of the time you’ll use Arrays when you want to group similar values. In our example, we can for instance group the names of all the people we want to greet in an Array, like so: var nameArray = [&#39;Tom&#39;, &#39;Sara&#39;, &#39;Bob&#39;]. We can now access the individual values or treat all these values as a whole via properties that are specific to Arrays. An example of such an Array-specific property would be the length property, which returns us the number of values in the Array, like so: var numberOfPersons = nameArray.length. Let’s rewrite the greetingFunction so that it takes an Array of names as argument, rather than a single name.</p><pre>var myVariable = &#39;Hello&#39;;<br>var nameArray = [&#39;Tom&#39;, &#39;Sara&#39;, &#39;Bob&#39;];</pre><pre>var greetFunction = function(names) {<br> names.forEach(function(name) {<br>  var greeting = myVariable + &#39; &#39; + name;<br>  window.alert(greeting);<br> });<br> <br>}</pre><pre>greetFunction(nameArray);</pre><p>In the code snippet above, the greetFunction takes the nameArray variable as an argument. This Array is then accessible inside of the greetFunction as the names variable. In the greetFunction, we iterate over all the values of the names Array by use of an Array-specific function named forEach. Functions which are specific to a certain type of variable are called <strong>methods</strong> (another example would be the alert() method, which is a function specific to the window object). In the greetFunction, we thus invoke the forEach method on the names Array. This method iterates over each value of the Array, thereby taking a function as its parameter which will be executed on each iteration. The function that we pass in as an argument to the forEach method will in its own right receive the currently iterated value as its argument, thereby allowing us to manipulate each value of the Array. In our case, we’re concatenating the string &#39;Hello&#39; to each name variable before passing it to the window.alert() method. Thus, we now optimized our code so that we have to invoke the greetingFunction only once to greet all persons. Awesome!</p><p>One last important type of value you need to know about in JavaScript is <strong>object</strong>. The object type is the mother of all types. As a matter of fact, you can think of Arrays (and even functions) as special versions of the object type. The object type refers to a compound value where you can set properties that each hold their own values of any type. Examples of such properties in the Array type would be the forEach function or the length number. You can access these properties either with the dot notation (e.g. names.length) or the bracket notation (e.g. names[&quot;length&quot;]). JavaScript provides you with a whole host of built-in objects that you can use in your code to do all sorts of neat stuff like math computations (Math object), date and time manipulations (Date object), etc… It’s easy to create your own custom objects too, but that’s outside the scope of this tutorial. Objects are, however, key to managing complex code, since they allow you to free your mind to think at a higher level. It is therefore essential for you to master object-oriented programming, would you ever want to be taken seriously as a web developer.</p><h3>Interacting with the DOM</h3><p>By now, it should be obvious that HTML and JavaScript are two totally different technologies. HTML is made of declarative markup that allows you to describe a set of nested elements that make up your pages. JavaScript on the other hand is meant for describing computations. So how are we ever going to be able to have them communicate with each other? The attentive reader will remember from day 1 that the answer comes in the form of an object, namely the window object that is provided to us by the browser. This window object allows us to manipulate the browser into doing things like, for instance, drawing popup windows via its alert method. The actual wormhole between our HTML and Javascript, however, exists yet again in the form of an object which is present as a property on the window object, namely the window.document object. This object represents the entire page in your browser and contains the complete DOM tree (see day 1), so we can ask it to do things like finding an HTML element (a.k.a. DOM element) for us to manipulate. Before we can interact with the DOM, however, we have to wait for the browser to complete its creation. We thus have to write all our DOM manipulating logic inside the document’s DOMContentLoaded event handler. Say what?!</p><p>Behind the scenes of your browser, a lot is going on: files are being downloaded, users are clicking DOM elements, the mouse location is being tracked, … and the DOM tree is being created. All these happenings are causing events to be triggered by the browser. We can react to all these events using the addEventListener method, which is available on a multitude of browser objects that are able to emit events, including our beloved window.document object. The addEventListener method takes two arguments. The first argument is the name of the event we want to react to. The second argument is the so-called &quot;event handler&quot;, a function that contains the code that’s to be executed each time the respective event gets triggered. Let’s illustrate this by triggering a popup window after DOM creation is completed.</p><pre>window.document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br> window.alert(&#39;The DOM tree is now available to your code&#39;);<br>});</pre><p>Refreshing your browser triggers the event handling code (i.e. the alert method) seemingly instantly. There is, however, a tiny delay compared to the execution of code that would be situated outside of the event handler, a delay that makes all the difference for your DOM manipulating code. If you don’t believe me then try and add window.alert(&quot;The DOM tree is not yet available to your code&quot;); outside and after your event handling code, and you’ll see it being executed before instead of after your event handling code.</p><p>So now that we know where to place our DOM manipulating code, we might as well write some. Let’s write some code that changes the title of our website. To accomplish this, the first thing we need to do is fetch the &lt;h1&gt; element from the DOM tree. There are several ways to get access to DOM elements, but we’re going to use the querySelector method, which is available on the window.document object. This method takes a CSS selector (string) as an argument, thereby fetching the first element that matches this selector. The DOM element that is returned from the querySelector method is again an object with its own properties. We’ll use the textContent property to update its text. Here’s our code:</p><pre>window.document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br> var titleElement = document.querySelector(&#39;.hero-title&#39;);<br> titleElement.textContent = &#39;Howdy, this title was generated by JavaScript&#39;;<br>});</pre><p>In this piece of code, we fetch the &lt;h1&gt; element via its class name hero-title, much like we targeted this element in our CSS file, with a dot in front of the class name.</p><p>You now know how to store values in variables, write functions, fetch and manipulate DOM elements and add event listeners. You also know a bit about the value types called Arrays and Objects. In other words, you’ve acquired enough skills to get those tabs to work.</p><h3>Adding tab functionality</h3><p>Before we start coding for our tab functionality, it’s a good idea to take a step back and look at the problem we’re facing. Only clearly defined problems can give rise to clearly defined solutions, which in turn can give rise to clean, simple and maintainable code. I know it’s tempting to just dive into coding without proper analysis, especially when dealing with simple problems like say, for instance, a tab navigation component. Most simple coding problems are, however, more intricate than you’d expect. I’ve already thought long and hard about the problems at hand. Have you?</p><p>As a matter of fact, I already had the tab functionality in mind when we implemented its markup and styling yesterday. In our HTML markup, we provided every tab link with a href attribute, specifying the id attribute of the tab pane it is supposed to target (go have a look in your HTML). We also styled it in such a way that, in order for a tab to be selected, we need only to toggle the active class on both the tab link element and its corresponding tab pane element. With this elegant setup, we are now able to breath live into our tabs with a minimal amount of uncomplicated JavaScript logic. Put simply, the only thing that’s required from our JavaScript, is to attach a click event handler to each tab link element. This event handler will need to search for the correct tab pane and toggle the active class in the appropriate places.</p><p>Let’s have a look at the code, shall we? Don’t be intimidated by the parts that are way over your head for now. We’re going to cover this code in detail in a bit.</p><p><em>Replace the content of your “script.js” file with the code snippet below.</em></p><pre>window.document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br> var tabLinks = window.document.querySelectorAll(&#39;.tab-links-item&#39;);<br> var tabLinksArray = [].slice.call(tabLinks);<br> tabLinksArray.forEach(function(tabLink) {<br>  tabLink.addEventListener(&#39;click&#39;, function(event) {<br>   event.preventDefault();<br>   if(!tabLink.classList.contains(&#39;active&#39;)) {<br>    // update tab links<br>    tabLink.parentNode.querySelector(&#39;.tab-links-item.active&#39;).classList.remove(&#39;active&#39;);<br>    tabLink.classList.add(&#39;active&#39;);</pre><pre>// update tab panes<br>    var targetPane = window.document.querySelector(tabLink.getAttribute(&#39;href&#39;));</pre><pre>targetPane.parentNode.querySelector(&#39;.active&#39;).classList.remove(&#39;active&#39;);<br>    targetPane.classList.add(&#39;active&#39;);<br>   }<br>  });<br> });<br>});</pre><p><em>Save, refresh and boom, your tabs should now be functional.</em></p><p>Reading through this snippet of code, you undoubtedly recognize some of the JavaScript constructs we talked about before. Despite some lines you may not fully understand, I hope the general idea of what is being accomplished does not elude you. Now, before we dive into the nitty-gritty details, I’d like to give you one more general pro-tip: <strong>when opening brackets of any kind, immediately close them before putting any content between them</strong>. Brackets that are not properly paired will break your code and are horrible to debug! In the code above, the opening brackets on the first line are closed only on the last line. I dare you to remember closing them after you’ve finished writing everything in between. Proper indentation might help keep an overview, but still, adhering to this advice will probably save you lots of dreadful debugging hours over time.</p><p>Now let’s have a closer look at the code we just implemented, with special attention to those parts you might not fully grasp yet. First thing to note, is that we’re gonna have to fetch and manipulate DOM elements, so we’re required to wrap our code in a DOMContentLoaded event handler. We’ve already seen how to do this. It should be clear that all code from line 2 to 19 is contained within this event handler, and will thus only be triggered when the DOM tree has become available to our code.</p><p>In the browser, navigating from one tab to another is accomplished by clicking a tab link. This means that each tab link element has some JavaScript logic attached to it. The first step into adding this logic to the tab links is to fetch the respective elements from the DOM, which is exactly what we’re doing on line 2 of our code. All tab link elements are stored in a variable named tabLinks. We would now like to iterate over these elements, thereby attaching the required logic to each tab link element. The Array-specific forEach method sure would come in handy here, but this requires us to have the tab links stored in an Array. The querySelectorAll method returns a so-called NodeList instead, an Array-like object that doesn’t support the forEach method. Through some JavaScript trickery, we can, however, convert this Array-like object into a proper Array. This is accomplished on line 3, thereby storing an Array of tab link elements in a variable named tabLinksArray. We can now thus iterate the tab link elements by calling the forEach method on the tabLinksArray variable. For those who’d like to understand what exactly is going on in line 3, here it goes: an Array-like object can be converted into a proper Array by use of the slice method. The slice method is, however, an Array-specific method. Thankfully, JavaScript makes it easy for us to invoke a method as if it belongs to a different host object via the call method. When we invoke the slice method on line 3, we thus invoke it on the Array-like object that’s passed in as an argument to the call method, rather than on the empty Array [] we are borrowing it from. The result is the Array-like object being converted into an Array, which gives us access to the extensive list of useful methods the latter has at its disposal. Capiche?</p><p>On line 4, we then iterate over all tab link elements by calling the forEach method on our tabLinksArray variable. We already learned that this method receives a function which will get executed on each iteration. In our case, there are three tab link elements in our tabLinksArray, so the code from line 5 to 18 will get executed three times as well. On each iteration, the currently iterated tab link element is made available to this piece of code in the capacity of the variable named tabLink.</p><p>Our goal now is to attach some logic to each tab link, which is to be executed when the tab link in question is clicked on. In JavaScript lingo, this can be translated to attaching a click event handler to each tab link. In the same manner we added a DOMContentLoaded event handler to our window.document object on line 1, we shall now thus add a click event handler to each tab link element on line 5. The addEventListener method is indeed available on any element in the DOM tree. Note that any event that is triggered by your browser is associated with an event object which holds information about the event. On line 5, we’re actually capturing this event object by passing the event handler an aptly named variable event as its argument. The reason why we need this event object, is that we want to prevent the browser from executing some default behavior associated with a click event on a tab link. The tab link elements are after all &lt;a&gt; elements with href attributes containing selectors (in contrast to class selectors which are preceded by a dot, id selectors are preceded by a hashtag). The default behavior of a browser when clicking such a link element would be to scroll to the DOM element with the respective id attribute. We prevent the browser from doing this by calling the event object’s preventDefault method on line 6.</p><p>Ok, so now we arrive at the heart of the matter. Line 6 to 17 will get executed every time a tab link is clicked on. It is here that we house the logic that makes our tab navigation tick. What does it need to do in human speak? First, it has to check whether or not the clicked tab link has the class active attached to it. If it does, than the clicked tab is already selected and we need not do anything. If it doesn’t, we have to add the active class to the clicked tab link and its corresponding tab pane, and remove this class from the tab link and tab pane that were previously selected. And that’s all there is to it! The CSS we implemented on day 2 will take care of the rest. So how do we go about this in JavaScript? Let’s see…</p><p>First we have to check whether or not the currently clicked tab link has the class active assigned to it. We have access to this tab link as a DOM element via the tabLink variable that was passed into our forEach method. Conveniently, any DOM element has a classList object at its disposal (unless you’re using Internet Explorer 9 as a browser — see the &quot;Refactoring to jQuery&quot; section below). This object provides us methods by which to add, remove and toggle classes on a DOM element. It also allows us to check if a class has been assigned to a given DOM element via its contains method. We can thus check for the presence of the active class on the tab link, like so: tabLink.classList.contains(&#39;active&#39;). This JavaScript statement resolves to a value of the boolean type. A boolean has only one of two possible values, namely true or false. A boolean preceded by an exclamation mark is negated, meaning true becomes false and vice versa. We need to switch tabs if, and only if, the active class is absent from the clicked tab link. There are quite a few ways we can express a conditional like this in our program logic, of which the if statement is the most common one. This statement requires a boolean between its parentheses, and has its logic executed only if this boolean resolves to true. On line 7, we require the active class to be absent from the clicked tab link for the logic on line 8 to 16 to be executed.</p><p>Before we activate a clicked tab link, we’d better deactivate the previously active tab link. Indeed, only one tab should be active at any given time. Fetching this previously activated tab link can be achieved with the querySelector method. Contrary to the querySelectorAll method, this method returns only one DOM element, and that’s all we need here. On line 9, we are thus able to immediately access this DOM element’s classList property to remove the active class. Note that we’re calling the querySelector method on the tab link element’s parentNode property instead of the window.document object. The reason for this is twofold. First, it’s better for performance reasons. Instead of having to search through the entire DOM tree, we now limited the search area to only those elements that live inside the tab link’s parent element (which in this case is the nav element with class tab-links). Second, it ensures that we contain our JavaScript logic to this tab component only. Imagine having more than one tab component on your website with the same classes on them. By limiting our DOM manipulation to the tab link’s parent element, we made sure that no other tab components are affected. Adding the active class to the clicked tab link on line 10 now has our tab links sorted. The only thing that’s left for us to do, is to activate the appropriate tab pane. We already know that each tab link has the id selector for its target pane specified in its href attribute. On line 13, we’re using the getAttribute method to fetch this value from the href attribute, thereby passing it as an argument to the querySelector method. The result is that we capture the targeted tab pane element in a variable named targetPane. This variable can now be used on line 15 and 16 to toggle the active class on the appropriate tab panes, much like we did on line 9 and 10 for our tab links.</p><p>And with that, we got our tab component functionality covered. Quite challenging for a beginning web developer, I know. Maybe you should consider grabbing a coffee, since we’re about to rewrite it all in jQuery…</p><h3>Refactoring to jQuery</h3><p>Just like we imported Bootstrap’s CSS file in our web page to help us out with its styling, we can also import <a href="https://jquery.com/">jQuery</a>’s JavaScript file to help us out with its behavioral aspects. Let’s import jQuery functionality by adding the following link tag to the &lt;head&gt; of the &quot;index.html&quot; file: &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js&quot;&gt;&lt;/script&gt;. Be sure to add this line of code before the line that’s importing the &quot;script.js&quot; file! We need to have our jQuery functionality loaded before we can use it in our script file.</p><p>jQuery at its core is a DOM manipulation JavaScript library. It’s currently the most popular JavaScript library. The jQuery JavaScript file is packed with JavaScript functions aimed at simplifying tasks like DOM tree navigation and DOM manipulation. The main usage style of jQuery is via the $ function, which is a factory method for the jQuery object. You can use this function to create new DOM elements from scratch or retrieve existing elements from the DOM tree. Say for example that you’d want to retrieve all elements with class tab-links-item from your DOM tree. Using the jQuery factory method, you can do this like so: $(‘.tab-links-item’);. Note that this syntax is a lot simpler than the pure JavaScript equivalent window.document.querySelectorAll(‘.tab-links-item’). It’s also important to note that the jQuery factory method returns a jQuery object referencing all matching elements in the DOM tree, rather than a NodeList as returned by the querySelectorAll method. This jQuery object has methods attached to it that are aimed towards manipulating the referenced elements, again through simplified syntax. Adding a click handler to all tab links, for instance, can be achieved like so: $(&#39;.tab-links-item&#39;).click(function() {//click handler logic here});. No more having to convert NodeLists into Arrays, no more forEach loops, no more addEventListener methods. Mind you, all these steps are possibly still executed inside jQuery’s JavaScript file, but that’s none of our concern.</p><p>Next to simplified syntax, another advantage of using the jQuery JavaScript library is browser compatibility. JavaScript is not written in stone. Every now and then, a new JavaScript specification hits the market. Likewise, new browser versions are released once in a while, thereby gradually integrating the newest JavaScript specification. In the end though, the responsibility of actually updating those browsers to their newest version lays in the hands of the end-user. At the time I am writing this for example, a lot of people are still using the outdated Internet Explorer 9 as their default browser. This browser doesn’t support the ClassList property we used in our code above, rendering our tab component useless in the hands of folks that are out of step with browser versioning. When using jQuery, however, you don’t have to worry about this nonsense. All jQuery methods are guaranteed to work in Internet Explorer 9. For adding, removing and checking the existence of classes on DOM elements, jQuery provides us with the addClass, removeClass and hasClass methods, respectively. Behind the scenes, jQuery may or may not use the ClassList property to fulfill these actions, but again, that’s none of our concern.</p><p>If you would argue that using jQuery is just the easy way out, which comes at a performance cost as well, then I would agree. Still, although there’s a tendency in the web development community to move away from jQuery, the majority of websites out there is still supported by it. Any serious web developer will get confronted with jQuery sooner or later, which is why I think it’s a good idea to introduce you to it now. Let’s have a look at the jQuery version of our tab component functionality.</p><p><em>Replace all content in your “script.js” file with the following:</em></p><pre>$(window.document).ready(function() {<br> $(&#39;.tab-links-item&#39;).click(function() {<br>  if( !$(this).hasClass(&#39;active&#39;) ) {<br>   // update tabs<br>   $(this).siblings().removeClass(&#39;active&#39;);<br>   $(this).addClass(&#39;active&#39;);</pre><pre>// update panes<br>   var $targetPane = $($(this).attr(&#39;href&#39;));</pre><pre>$targetPane.siblings().hide();<br>   $targetPane.show();<br>  }<br> });<br>});</pre><p>By refactoring our code to jQuery, we made it more compact, more readable and more widely supported throughout the browser landscape. Let me quickly guide you through it. On line 1, we execute the factory method on the window.document object, thereby converting this object into its jQuery equivalent. This enables us to execute the jQuery ready method on it, which is passed in a function as argument that will get executed whenever the DOM tree is fully loaded. Similarly, we pass in a function as argument to the click method, which gets executed each time a tab link is clicked. Before refactoring our code, this click handler had the currently iterated tab link passed in as its argument. This is no longer the case with jQuery. We accommodate for the absence of this variable by use of the jQuery $(this) object on line 3, 5, 6 and 9. Another thing to note is the first character of the variable name $targetPane on line 9. This dollar sign is simply part of the variable’s name, and has no effect on its capabilities. Adding the dollar sign in front of a variable name is just best practice for reminding us that a jQuery object is contained within, and thus jQuery methods are available on it. Examples of such jQuery methods used in our code are hasClass, removeClass, addClass, siblings, attr, show and hide. If you’d like to have a deeper understanding of jQuery and its methods, I urge you to dig into its <a href="https://api.jquery.com/">documentation</a>.</p><h3>Adding some magic</h3><p>You’ve undoubtedly noticed the enticing “Show me some magic” button on your web page. However, when you click this button, it’s not exactly spraying rainbows, is it? Let’s fix that. What we actually want to achieve is that the button triggers a modal popup, and we’ll have Bootstrap help us out. We’ve already let our Bootstrap CSS file take care of the button styling. In its <a href="https://getbootstrap.com/javascript/#modals">documentation</a>, you can also find the required HTML markup for a Bootstrap modal. We can simply copy paste this markup in our HTML file, and then Bootstrap will style it into a beautiful modal for us.</p><p><em>Add the following code to your “index.html” file. You can place it anywhere in the </em><em>&lt;body&gt; tag, but I recommend placing it right behind the ‘show-me-some-magic button’ markup.</em></p><pre>&lt;!-- Modal --&gt;<br>&lt;div class=&quot;modal fade&quot; id=&quot;myModal&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;myModalLabel&quot; aria-hidden=&quot;true&quot;&gt;<br> &lt;div class=&quot;modal-dialog&quot;&gt;<br>  &lt;div class=&quot;modal-content&quot;&gt;<br>   &lt;div class=&quot;modal-header&quot;&gt;<br>    &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;<br>    &lt;h4 class=&quot;modal-title&quot; id=&quot;myModalLabel&quot;&gt;This is a bootstrap modal&lt;/h4&gt;<br>   &lt;/div&gt;<br>   &lt;div class=&quot;modal-body&quot;&gt;<br>    &lt;p&gt;<br>     Yep, in 3 days you&#39;ll be throwing modals like these into people&#39;s faces!<br>    &lt;/p&gt;<br>    &lt;p&gt;<br>     Who&#39;s boss ...<br>    &lt;/p&gt;<br>   &lt;/div&gt;<br>   &lt;div class=&quot;modal-footer&quot;&gt;<br>    &lt;button type=&quot;button&quot; class=&quot;btn btn-default&quot; data-dismiss=&quot;modal&quot;&gt;Close&lt;/button&gt;<br>   &lt;/div&gt;<br>  &lt;/div&gt;<br> &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Note that we’ve added our own custom content to the modal header and body.</p><p>When you refresh your browser now, there’s no modal in sight. This might seem odd, but actually it’s not. Modals should only be displayed when requested by a user action, in our case a button click. Any other use of modals is just plain irritating. That’s why the Bootstrap CSS file makes sure that our modal is initially hidden by setting its display property value to none;. Then how do we make our modal visible? Yet again, there’s Bootstrap to the rescue. In addition to its CSS file, Bootstrap also provides us with a JavaScript file to bring its components to life. This Bootstrap JavaScript depends on jQuery, so we’ll have to make sure to import it after our jQuery. Add the following line of code to the &lt;head&gt; of your &quot;index.html&quot; file, right after the line that imports jQuery: &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;. Just like its CSS, Bootstrap’s JavaScript will target HTML attributes to get its job done. In order for our button to act as a trigger for our Bootstrap modal, we thus have to attach the appropriate attributes to it. More specifically, we have to attach a data-toggle attribute with value modal and a data-target attribute with value #myModal (i.e. the targeted modal’s id selector) to our button. Its HTML markup should look like this:</p><p><em>Replace the ‘show-me-some-magic button’ markup in your “index.html” with the following:</em></p><pre>&lt;button class=&quot;btn btn-primary btn-lg&quot; data-toggle=&quot;modal&quot; data-target=&quot;#myModal&quot;&gt;<br> Show me some magic<br>&lt;/button&gt;</pre><p>Clicking the button should now trigger the modal.</p><p>And with that, we have yet again illustrated the power of using a framework in our web development process. Although they are maybe the most famous ones at the time of writing, Bootstrap and jQuery are definitely not the only tools that can greatly increase your web development capability and efficiency. Because the web development community is so lively, there’s a framework, library or plugin for almost any existing web development problem. It’s up to you to find the ones that solve your specific problems best. Also keep in mind that learning a framework is not the same as learning a language. Where knowledge of a framework is useful only within that specific framework, knowledge of a language (HTML, CSS, JavaScript) can be ported anywhere. It is thus a good idea to occasionally get your hands dirty, like we did when implementing our tab component functionality.</p><h3>Going live</h3><p>Save for our twitter bird, our website is now finished! Since the tweet that will urge people to visit your website will preferably contain a link to this website (which we don’t have yet), we’ll postpone implementing the twitter bird functionality for just a bit. Let’s first push our website to the World Wide Web so that it’s accessible for anyone to visit. How can we do that? Maybe it helps to have a look at a definition for the World Wide Web.</p><blockquote>The World Wide Web is a collection of text documents and other resources on web servers, linked by domain names, usually accessed by web browsers.</blockquote><p>We already have our collection of text documents and other resources that make up our website. What we are still missing is a domain name for our website, and a web server to store our website files on. We can thus identify three steps into pushing your website to the World Wide Web. Step one: purchase a domain name from a domain name registrar. Step two: purchase some server space from a web hosting company, and put your website files on it. Step three: notify your domain name registrar on where to find your website files.</p><p>The files that make up your website are stored locally on your computer, and are also served from this exact location to your browser. When your “index.html” is opened in your browser, you can indeed see the path to this file in your browser’s address bar. Typing this path in another computer’s browser address bar will obviously not return your website. In other words, we need a domain name that will direct the browser to the files that make up your website. A domain name is something that needs to be purchased from a domain name registrar, an organization or commercial entity that manages the reservation of Internet domain names. Some of the most popular ones are <a href="https://www.namecheap.com/">namecheap</a>, <a href="https://godaddy.com/">godaddy</a> and <a href="https://www.1and1.com/">1&amp;1</a>. So if you’d like to share your website with people around the globe, the first step is purchasing a domain name of your choosing from one such domain name registrar. Expect a price of about 10 USD per year.</p><p>The next step is to put your website files on a server. You can think of a server as a computer whose sole purpose is to share data and resources. Servers in general are more powerful and reliable than standard personal computers. Thus, by putting your website files on a server, you’re making sure that your website will be available to anyone, from anywhere, at anytime. Server space can be purchased from a web hosting company. Some of the most popular ones are <a href="https://www.bluehost.com/">bluehost</a>, <a href="https://godaddy.com/">godaddy</a> and <a href="https://www.hostgator.com/">hostgator</a>. For now, I recommend going for the cheapest pricing plan available. Expect a price of about 20 USD per year. Once you’ve purchased your server space, you should get access to a dashboard or control panel from which you can manage it. Now is the time to put your “index.html” file and your images, scripts and styles folders with their respective contents in the so-called document root folder of your server space. The name of this folder and the procedure to store your website files depend on your web hosting company. Most probably you’ll have access to the folder structure of your server space via some sort of file management tool on your dashboard. The name of your document root folder will most likely be “public_html”. Most web hosting companies have good customer support, so don’t hesitate to reach out to them for help. In any case, the end result should be the contents of your local “my-first-website” folder being copied to the document root folder of your server space.</p><p>Now that you have purchased a domain name and some server space, all that’s left for us to do is to link them together. When people type in your domain name in their browser, they should be directed to your server space and nowhere else. How can you achieve this? You just have to inform your domain name registrar on where to find your website files. Put simply, your domain name registrar will then communicate this information to a set of selected servers. Subsequently, when browsers are looking for your domain name, they will in turn communicate with a set of selected servers to acquire information on the location of your website files and then fetch them. You can inform your domain name registrar on the location of your website files by means of the name servers provided to you by your web hosting company. Typically, these name servers were communicated to you in the web hosting companies subscription confirmation email and have a form similar to ns.webhostname.com. If you can’t find them in your subscription confirmation email, you should be able to find them via your web hosting company’s customer support. As with your web hosting company, your domain name registrar should have a dashboard of some sort where you can log in to manage your domain names. Here, you can provide the name servers of your web hosting company to link them to the domain name that you purchased. The manner in which to do this is registrar-specific, but should be self-evident. If it isn’t, then contact your domain name registrar’s customer support to help you out. No need to panic if your domain name doesn’t instantly link to your website when you’ve inputted the name servers. It takes some time for the appropriate servers to propagate this information around the world.</p><h3>Sharing on Twitter</h3><p>Now that your website has become part of the World Wide Web, we can put that twitter bird to work. In your “index.html” file, the twitter bird is represented by a link element that is styled by Fontawesome. All we need to do to make your twitter bird functional, is to update the value of its href attribute so that it directs to the twitter API (Application Programming interface) with some parameters attached.</p><p><em>In your “index.html”, replace your twitter bird &lt;a&gt; element with the following:</em></p><pre>&lt;a class=&quot;nav-twitter fa fa-twitter fa-2x&quot; href=&quot;<a href="https://twitter.com/intent/tweet/?text=How">https://twitter.com/intent/tweet/?text=How</a> to become a web developer in 3 days&amp;url=<a href="http://www.fredericaerts.com/external/developer-in-3-days/&amp;via=fredericAerts">http://www.fredericaerts.com/external/developer-in-3-days/&amp;via=fredericAerts</a>&quot; target=“_blank&quot;&gt;&lt;/a&gt;</pre><p>Clicking the twitter bird in your browser will now present a ready made tweet in a separate browser tab. The content of this ready made tweet will be determined by the parameters you attach to the web address that is passed into the href attribute. In this case, there are 3 parameters attached, namely text, url and via. You can customize their values to create a tweet of your liking.</p><h3>Final thoughts</h3><p>You didn’t really think you were going to become a professional web developer in 3 days, did you? If you did, I apologize for deceiving you. It takes a little more time.</p><p>And yet, in a way it is true that one can learn to build a website in a relatively short timespan. HTML, CSS and JavaScript have learning curves that are quite shallow in the beginning. It does get steeper when it’s time to pass from building crappy looking websites to professionally looking websites. To become a professional web developer, I recommend that you spend some time pulling your hair out while trying to build some crappy stuff, learn from it, and build something a bit better the next time. Do this time and time again, and you will be guaranteed a prosperous and happy future. I think.</p><p><em>“How to become a web developer in 3 days” is a beginner-friendly series designed to help aspiring web developers get acquainted with the languages that make up a website.</em></p><p><strong><em>Explore the series:</em></strong></p><ul><li><a href="https://medium.com/@frederic_aerts/day-1-what-websites-are-made-of-2f572662db71"><em>Day 1: What websites are made of</em></a></li><li><a href="https://medium.com/@frederic_aerts/day-2-structure-and-styling-2576c63f0258"><em>Day 2: Structure and styling</em></a></li></ul><p><em>Originally published at </em><a href="https://www.fredericaerts.com/external/writing/developer-in-3-days/behavior-and-going-live/"><em>www.fredericaerts.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d8d4a73afba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 2: Structure and styling]]></title>
            <link>https://frederic-aerts.medium.com/day-2-structure-and-styling-2576c63f0258?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/2576c63f0258</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 10:30:01 GMT</pubDate>
            <atom:updated>2020-11-26T01:54:03.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJtkfHoT_b9_jDs1x3A_2A.jpeg" /></figure><p><em>“How to become a web developer in 3 days” is a beginner-friendly series designed to help aspiring web developers get acquainted with the languages that make up a website.</em></p><p><strong><em>Explore the series:</em></strong></p><ul><li><a href="https://medium.com/@frederic_aerts/day-1-what-websites-are-made-of-2f572662db71"><em>Day 1: What websites are made of</em></a></li><li><a href="https://medium.com/@frederic_aerts/day-3-behavior-and-going-live-5d8d4a73afba"><em>Day 3: Behavior and going live</em></a></li></ul><h3>Day 2: Structure (HTML) and styling (CSS)</h3><blockquote><em>For the things we have to learn before we can do them, we learn by doing them.</em></blockquote><blockquote><em>— Aristotle</em></blockquote><p><strong>Yesterday we set out to build </strong><a href="https://www.fredericaerts.com/external/developer-in-3-days/"><strong>this website</strong></a><strong> in 3 days time. We already learned that websites are in essence made using three languages, namely HTML, CSS and JavaScript. Now that we’ve gotten familiar with the building blocks of a website, the time has come to build one of our own. Today we’ll focus on the HTML and CSS of our website. But before we go ahead and do that, let’s get ourselves organized…</strong></p><h3>Getting organized</h3><p>Getting organized is the first and most important part of building websites. Professional web developers do not succumb to the temptation of creating a mess in order to move more quickly. Instead, they start with the end-goal in mind and organize themselves accordingly. The advantages become clear when you start writing CSS for a decently sized website. Given the characteristics of the language, CSS files can get very bloated very fast. In order to keep our CSS code easy to read and maintain, we thus have no choice but to think out an effective organization for it. The approach we’ll use is modular in nature. Much like a chef has his ingredients lined up ready to go, we’ll have our CSS file cut up into multiple files that are readily available to our website. When everything is in its designated place, then we are able to think and work efficiently. Here’s our mise en place:</p><p><em>Create a folder on your computer named “my-first-website”. This will be the workspace for your website. In this folder, create your “index.html” file and add the following content:</em></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br> &lt;head&gt;<br>  &lt;title&gt;Beginner page&lt;/title&gt;<br> <br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/reset.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/base.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/grid.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/helper-classes.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/header.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/hero.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/tabs.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=“styles/footer.css&quot;&gt;<br>  &lt;script src=&quot;scripts/script.js&quot;&gt;&lt;/script&gt;<br> &lt;/head&gt;<br> &lt;body&gt;<br> &lt;/body&gt;<br>&lt;/html&gt;</pre><p><em>Now create your CSS files in accordance with the paths specified in the href attribute of your link tags. This means creating a subfolder named “styles” in your workspace, in which you place eight (empty) CSS files with names matching those in the link tags. Likewise, create an empty JavaScript file named “script.js” in a subfolder named “scripts”. Finally, add an empty subfolder named “images” in your workspace. This is where you will house your images later on. Your workspace directory should thus look like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*ql6EL0qjiFwSE4ah.jpg" /></figure><p><em>Now open your “my-first-website” folder in your code editor (e.g. Sublime Text). From now on, we’ll be working in our code editor.</em></p><p>Each CSS file in our workspace is aimed at either styling a specific structural module in our website, or grouping CSS rules that contribute to a specific task in the overall styling of our website. Laying the groundwork for the styling of our website is the first task we’ll address, and for that we’ll use our “reset.css” file.</p><p>Maybe you remember from yesterday’s article that browsers have built-in default styling rules to make unstyled websites appear more legible. Header elements for example are styled bolder and bigger than paragraphs by most browsers, and often default top and bottom margins are applied. These default styles can vary from browser to browser. Therefore, if we want our website to look the same in every browser, it’s a good idea to reset the styling of all HTML elements to a consistent baseline before we start adding our own custom styles. Since there are many CSS resets freely available on the internet, it would be a waste of time to write this CSS ourselves. A <a href="https://meyerweb.com/eric/tools/css/reset/">nice CSS reset</a> for zeroing out styles on all elements is the one from Eric Meyer. I’ve tweaked this CSS reset a little bit so that it matches the specific needs of our website. Now let’s use it.</p><p><em>Copy paste Eric Meyer’s CSS reset code it in your “reset.css” file;</em></p><pre>/**<br> * Eric Meyer&#39;s Reset CSS v2.0 (<a href="http://meyerweb.com/eric/tools/css/reset/">http://meyerweb.com/eric/tools/css/reset/</a>)<br> * <a href="http://cssreset.com/">http://cssreset.com</a><br> */<br>html, body, div, span,<br>h1, h2, h3, h4, h5, h6, p,<br>a, strong, ul, li, article,  <br>footer, header, nav, section {<br> margin: 0;<br> padding: 0;<br> border: 0;<br> font: inherit;<br> font-size: 16px;<br> line-height: 1.4em;<br> vertical-align: baseline;<br>}<br>/* HTML5 display-role reset for older browsers */<br>article, aside, details, figcaption, figure,<br>footer, header, hgroup, menu, nav, section {<br> display: block;<br>}<br>body {<br> line-height: 1;<br>}<br>ol, ul {<br> list-style: none;<br>}</pre><p>You can test your CSS reset by adding a h1 header and a paragraph to your “index.html”. Both should have the same styling in your browser. If not, start debugging!</p><p>When you take a closer look at this CSS reset, you’ll notice there are a couple of things we can learn from it. First, there are a lot of HTML tags we haven’t seen before. Take a minute to glance through them. No need to memorize them all! Another thing to note is the use of comma’s in our CSS selectors. The comma in a CSS selector separates multiple selectors that have the same style. In other words, all CSS declarations in between curly braces apply to each of the comma-separated HTML tags in front of them. Finally, note the presence of CSS comments. CSS comments are a handy way of adding helpful notes and hints to your CSS, thereby making sure that people who read your code understand what’s going on.. By using comments to make your stylesheets more readable, your CSS will be easier to maintain in the future. A CSS comment is added by enclosing it between /* and */ characters. Everything in our CSS that’s in between these opening and closing comment characters will be ignored by the browser, and so will the comment characters themselves.</p><p>Now that we have turned off browser default styles, we can start layering our own styles on our HTML elements. Let’s make a rule for ourselves to use our “base.css” file for styling HTML tags only, and our remaining CSS files for targeting classes only. This way we get a logical progression in the styling of our website. First, we reset browser default styling in our “reset.css”. Subsequently, we layer on our own default styling for HTML tags in our “base.css”, and then finally, we have the opportunity to layer on element-specific styles by targeting element class attributes in the appropriate CSS files. Since the browser processes our CSS files one by one from top to bottom, it should be clear that the order in which we declare the link tags in the head of our “index.html” is of great importance (see CSS specificity on day 1).</p><h3>The CSS box model</h3><p>Now before we go ahead and build up our website, there’s just one more concept you need to familiarize yourself with, and that is that <strong>every HTML element is a rectangular box</strong>. We can represent this box like so;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*96O8ySgOO93Zjpr3.jpg" /></figure><p>We’ve already seen that we can manipulate the margins of this box using CSS. Margins don’t affect the size of the box itself, but they affect the distance of the box in respect to the other boxes in our website, and thus they are an important part of the CSS box model. Evidently, we can also use CSS to adjust the padding and border properties of our HTML elements. Where it gets confusing is when we also declare specific height and/or width properties on those elements. If we would for example setup our CSS to give an element a padding of 20px and a width of 100px, then the perceived width of this element in our browser would be 120px. This is totally counter-intuitive since this perceived width does not match the width property in our CSS. There is, however, the CSS property box-sizing which conveniently allows us to change the box model so that an element&#39;s specified width and height aren&#39;t affected by its padding or borders. It’s common practice to apply this rule to all elements.</p><p><em>Insert this piece of code in your “base.css” file;</em></p><pre>* {<br> box-sizing: border-box;<br>}</pre><p>It could be argued that this piece of code belongs in our “reset.css” rather than our “base.css” file. You say to-may-to, I say to-mah-to. Let’s move on…</p><p>Note that the asterisk is a special CSS selector that simply targets all elements. So from now on, the width and height properties in our CSS include content, padding and border, but not the margin. Neat indeed! But don’t you start thinking that all boxes are created equal now… Because they’re not!</p><p>Based on their default behavior as a box in the browser, we can distinguish 3 types of HTML elements. There are <strong>block elements</strong>, which by default take up the full width of their parent element and enforce line breaks. The h1 header and paragraph elements we used yesterday are examples of block elements. Then there are <strong>inline elements</strong>. Consider you want a word in a paragraph marked up as a link to another website. We don’t want a line break to be enforced on that word right? The link tag is therefore an example of an inline element, which is by default just as wide as its content and doesn’t enforce a line break. Don’t try to set a top margin, bottom margin, height, or width on an inline element, ’cause it’s not going to work! Finally there are <strong>inline-block elements</strong>, which differ only in respect to inline elements in that their margins are all adjustable, just as their width and height. An example of such an element would be an image.</p><h3>Walking the walk</h3><p>Alright, we’ve spent approximately one and a half day talking about website development. We’ve learned a lot, and you’re a real trooper for still hanging in there. But although being knowledgeable is mighty fine, it’s of no value until you put this into practice. In other words, it’s high time we get our hands dirty. So hold on to your hats, because we’re going to move fast in building something to be proud of by the end of the day.</p><p>Looking at the beginner page of our website, we can distinguish six sections. Here they are from top to bottom:</p><ul><li><strong>Header</strong><br> contains navigation bar and twitter logo -&gt; styled mainly in “header.css” file</li><li><strong>Hero</strong><br> contains page title and web languages logo image -&gt; styled mainly in “hero.css” file</li><li><strong>Main content section</strong><br> contains subtitle, some paragraphs and a button -&gt; styled mainly in “base.css” file</li><li><strong>Devices image</strong><br> contains image of different devices on which our website will shine -&gt; styled mainly in “helper-classes.css” file</li><li><strong>Tab section</strong><br> contains subtitle, paragraph and tabs -&gt; styled mainly in “tabs.css” file</li><li><strong>Footer</strong><br> contains website info -&gt; styled mainly in “footer.css” file</li></ul><p>On a side note, the term “hero” is commonly used for a website’s main banner. It is believed to stem from the marketing industry, where “hero” denotes the main focal point of an advertisement.</p><p>Now let’s build them sections one by one…</p><h3>Header</h3><p>First notice that the header bar covers the full width of the page, but the content of the navigation bar is positioned in the middle. Since this same pattern of centered content is returning in other sections of the page, it would be wise to create a wrapper for this content that can be reused in the other sections. For this purpose, we’ll use a block element (any semantically meaningful block element will do) decorated with the class content-wrapper. We’ll then target this content-wrapper class from our CSS to position it in the middle of the page.</p><p>The HTML elements we’ll use to construct our header are &lt;header&gt;, &lt;nav&gt; and &lt;a&gt;, which respectively define the boundaries of the header, the wrapper for our navigation links and the links themselves (including the twitter icon). We’re going to decorate them all with meaningful classnames too, so that we can target them from our &quot;header.css&quot; Here’s the HTML for our header:</p><p><em>Copy paste this HTML snippet into the body tag of your “index.html” file:</em></p><pre>&lt;header class=&quot;header&quot;&gt;<br> &lt;nav class=&quot;content-wrapper&quot;&gt;<br>  &lt;a class=&quot;nav-item active&quot; href=&quot;index.html&quot;&gt;Beginner&lt;/a&gt;<br>  &lt;a class=&quot;nav-item&quot; href=&quot;expert.html&quot;&gt;Expert&lt;/a&gt;<br>  &lt;a class=&quot;nav-twitter fa fa-twitter fa-2x&quot; href=&quot;&quot;&gt;&lt;/a&gt;<br> &lt;/nav&gt;<br>&lt;/header&gt;</pre><p>Now take a long, good look at this HTML snippet. Note that we have used the absolute minimum number of HTML tags necessary to describe the structure and meaning of the header content. If you know that the &lt;header&gt; and &lt;nav&gt; tags are block elements, and the &lt;a&gt; tag is an inline element, then try to imagine how their respective boxes will be positioned in the browser. Open your &quot;index.html&quot; in the browser and use its web development tools to inspect these elements! We already know what the content-wrapper class is for. How can we use the other classes to style our HTML elements in accordance with the design we’re after? Don’t worry about the absent twitter bird just yet, we’ll fix that in a minute.</p><p>The first thing we’ll address is the content-wrapper. The content-wrapper is a block element and thus has a default width of 100%. We can easily make a block element smaller by setting a CSS width property for it, and then center it by setting its left and right margins to auto. The content-wrapper class will be used throughout multiple sections of our website, so it makes sense to put this code in the generic CSS file named &quot;grid.css&quot;.</p><p><em>Add this CSS code to your “grid.css” file:</em></p><pre>.content-wrapper {<br> width: 750px;<br> margin-left: auto;<br> margin-right: auto;<br>}</pre><p>When you refresh your browser, you’ll see that the navigation links have moved away from the left side of your browser to a more centered position. When you inspect the &lt;nav&gt; element with your browser’s web development tools, you’ll see that it’s perfectly centered. All content within it will now be positioned in the middle of the page. Easy enough, right? Note that this code is not going to cut it on smaller (mobile) devices, but we’ll fix that later on.</p><p>Next up, the twitter bird! Did you notice the fa, fa-twitter and fa-2x classes on our last link element? These classes will be used by our CSS to style that link element, so that it gets a twitter bird as its content. This will obviously require some advanced CSS trickery way beyond the scope of this series, so we’re going to use an external CSS file to do it for us. To import this CSS file, add the following line of code to the &lt;head&gt; of your &quot;index.html&quot;: &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css&quot;&gt;. Refresh your browser and the twitter bird is in place. Mind = blown! With special thanks to <a href="https://fortawesome.github.io/Font-Awesome/">Font Awesome</a>, the iconic font, and CSS toolkit…</p><p>Still, the color of our twitter bird is off. And what’s that line on the bottom doing there? Well, these are default browser styles applied to link elements, which we’ll have to overwrite. Looking at other links throughout our <a href="https://www.fredericaerts.com/external/developer-in-3-days/">example website</a>, you’ll notice that most of them have a light blue color and none of them are underlined. It thus makes sense to style link elements this way in our “base.css” file:</p><p><em>Add this CSS code to your “base.css” file:</em></p><pre>a {<br> color: #6495ED;<br> text-decoration: none;<br>}</pre><pre>a:hover, a:visited, a:active, a:focus {<br> color: #6495ED;<br> text-decoration: none;<br>}</pre><p>Note that the color property has a hex code value. On day one of this series, we used the color name red to change the color of highlighted text. Obviously, the list of color names to choose from is limited. A more flexible (and popular) way of specifying colors with CSS is via hex codes, where the first two digits represent the red, the next two the green, and the last two the blue. Mixing these three colors together in different proportions gives us a huge color palette to work with. In the hexadecimal system, numbers (0-9) team up with letters (A-F) to create 16 possibilities per digit: [0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F]. And so, black would be represented by #000000, white by #FFFFFF, red by #FF0000, green by #00FF00, and blue by #0000FF. Looking at the hex code we’re using to color our links, we can see there’s a lot of blue (ED) mixed in, but also a substantial amount of red (64) and green (95). The result is a light blue, much like the twitter brand color.</p><p>Now blow the trumpet and bang the drum, because our header… still looks like crap. So let’s bring out the big guns and fill up that “header.css” file with some header-specific CSS rules. Here’s the code:</p><p><em>Fill up your “header.css” file with the following CSS:</em></p><pre>.header {<br> box-shadow: 0 0 2px 3px #EEEEEE;<br>}</pre><pre>.nav-item {<br> display: inline-block;<br> height: 60px;<br> padding: 20px;</pre><pre>color: #000000;<br> font-weight: bold;<br> text-transform: uppercase;<br>}</pre><pre>/* align first navigation item to left */<br>.nav-item:first-child {<br> padding-left: 0;<br>}</pre><pre>.nav-item.active {<br> color: #6495ED;<br>}</pre><pre>/* position twitter link vertically centered at right side of header */<br>.twitter-link {<br> padding: 15px 0;<br> float: right; <br>}</pre><p>Now that’s better! Can you figure out the purpose of each CSS rule by yourself? If you have doubts about the effect of a certain CSS property, just delete it and see what happens in the browser. If you have doubts about the syntax of a CSS property, just google it (I had to google the box-shadow syntax myself). Note that we’ve shown here that the default inline, inline-block, or block behavior of an element are interchangeable via the display property. In our case, we’ve changed the inline nav-item link elements into inline-block elements, so as to enable us to specify their height. Note also that it’s good practice to give small clickable elements some padding (rather than margins), thereby increasing their clickable surface. With everything you’ve learned so far, I consider the rest of this CSS code to be self-evident. Let’s move on…</p><h3>Hero</h3><p>Since all our hero content is centered horizontally, it’s tempting to think we need a content-wrapper in our hero like we did in our header. However, if you think about it, centering elements in respect to either a content-wrapper or a full-width element has exactly the same effect. We can thus omit the content-wrapper in our hero markup.</p><p><em>Add this HTML snippet right after the header closing tag in your “index.html” file:</em></p><pre>&lt;section class=&quot;hero&quot;&gt;<br> &lt;h1 class=“hero-title&quot;&gt;How to become a web developer in 3 days&lt;/h1&gt;<br> &lt;img class=“hero-image&quot; src=&quot;images/logo.png&quot;&gt;<br> &lt;a class=&quot;btn btn-success btn-lg&quot; type=&quot;button&quot; href=&quot;<a href="https://medium.com/@frederic_aerts/day-1-what-websites-are-made-of-2f572662db71">https://medium.com/@frederic_aerts/day-1-what-websites-are-made-of-2f572662db71</a>&quot; target=&quot;_blank&quot;&gt;<br>  Start building<br> &lt;/a&gt;<br>&lt;/section&gt;</pre><p>Note that the button in our hero is actually linking to another website, which is why an &lt;a&gt; tag is semantically more correct here than the perhaps more obvious &lt;button&gt; tag.</p><p>Looking at the rendered hero markup in your browser, the first thing you’ll notice is the missing image. As specified in the &lt;img&gt;’s src attribute, the browser is desperately looking for an image named &quot;logo.png&quot; in the images folder. You can help out the browser by downloading the image <a href="https://www.fredericaerts.com/external/developer-in-3-days//images/logo.png">here</a>, and then placing this (correctly named) image in the images folder of your workspace. If you’d like to use your own image instead, then that’s just fine by me. Just make sure that it is no bigger than needed, because images take up an awful lot of bandwidth.</p><p>Assuming that the h1 header will have the same font properties on all our webpages, it’s best to define these in our “base.css” file.</p><p><em>Add this generic CSS rule to your “base.css” file:</em></p><pre>h1 {<br> font-size: 35px;<br> font-weight: 700;<br> text-transform: uppercase;<br>}</pre><p>Now let’s focus on horizontally centering all hero content. We have already learned from our content-wrapper that we can center block elements by specifying their width and setting their left and right margins to auto, so our h1 element is covered. Since our image element (inline-block element) is supposed to enforce a line break, we might as well make it a block element too. Here are the hero-specific CSS rules for our h1 header and image element:</p><p><em>Add these CSS rules to your “hero.css” file:</em></p><pre>.hero-title {<br> width: 95%;<br> max-width: 550px;<br> margin: 0 auto;<br> padding: 15px;</pre><pre> background: #FFFFFF;</pre><pre> border: 1px solid black;<br>}</pre><pre>.hero-image {<br> display: block;<br> width: 80%;<br> max-width: 400px;<br> margin: 40px auto;<br>}</pre><p>Note that we’re using a combination of the width and max-width properties to make elements scale nicely on smaller devices, but prevent them from scaling out of proportion on larger devices.</p><p>Although our block elements are now centered nicely, our h1 header border makes it clear that its content is not. Horizontally centering text, inline and inline-block elements requires another, more straightforward approach than block elements, namely setting a text-align property on its parent…</p><p><em>Add this CSS rule to your “hero.css” file:</em></p><pre>.hero {<br> padding: 60px 0;</pre><pre> text-align: center;</pre><pre> background: #EEEEEE;<br>}</pre><p>Note that the text-align property gets inherited by the h1 element.</p><p>Now that’s looking better! But did you notice that the shadow on the header has disappeared? That’s because our hero is stacked on top of it. And since we’ve now specified a background color for our hero, it’s actually covering it. We can fix this by moving the header element upwards with the z-index property. Note that this property works only on positioned elements. So if you want, you can already bring back the header shadow by styling the header element, like so: position:relative; z-index:999;. Later on, when styling the header to stay fixed to the top of the screen while scrolling, we’re going to update this code again.</p><p>All that’s left for us to do now regarding the hero is to style its button. We could do that ourselves, and it wouldn’t be that difficult either. There is, however, an even easier way called <a href="https://getbootstrap.com/">Bootstrap</a>. Much like Font Awesome provided us with CSS to style our twitter bird in the header, Bootstrap can provide us with CSS to style commonly used components throughout the web. All we have to do is import the Bootstrap CSS and decorate our elements with the targeted classes. The classes that Bootstrap targets for styling a success button (btn, btn-success, and btn-lg) are already in place. All that’s left for us to do is import the Bootstrap CSS file by adding the following link tag to the &lt;head&gt; of our &quot;index.html&quot; file: &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css&quot;&gt;. Impressive, right? Styling buttons is just a tiny little fraction of what Bootstrap can do for us. It’s actually kind of a waste importing such a huge CSS file, just to use so little of its potential. The purpose of this course is only showing you how Bootstrap works. If you decide to use it in your own projects, then use it enough so that the CSS file import is justified. Also make sure you always import Bootstrap CSS before your own stylesheets, meaning that its link tag in the &lt;head&gt; should precede the others. That way, it’s easier to overwrite any Bootstrap styling we didn’t ask for, like for instance underlining links that are hovered over by the mouse. You can now fix this by adding a:hover { text-decoration: none; } to your &quot;base.css&quot; file.</p><h3>Main content section</h3><p>I hope we can agree that the main content section is not a component in itself like the header and hero. The subtitle (&lt;h2&gt;) and paragraphs within are indeed very generic in the sense that they’re not specific to any component. Thus, we can best style them in our &quot;base.css&quot; file. The button styling is already taken care of by Bootstrap. Here’s the required HTML and CSS for our main content section:</p><p><em>Add the following HTML snippet to your “index.html” file:</em></p><pre>&lt;section class=&quot;content-wrapper&quot;&gt;<br> &lt;h2&gt;This is the website you&#39;ll build&lt;/h2&gt;<br> &lt;p&gt;<br>  And you&#39;ll build it like a pro too...<br> &lt;/p&gt;<br> &lt;p&gt;<br>  In a &lt;a href=&quot;<a href="http://www.fredericaerts.com/#/writing/series/how-to-become-a-web-developer-in-3-days?article=day-1:-what-websites-are-made-from">http://www.fredericaerts.com/#/writing/series/how-to-become-a-web-developer-in-3-days?article=day-1:-what-websites-are-made-from</a>&quot; target=&quot;_blank&quot;&gt; 3 day tutorial&lt;/a&gt;, we&#39;ll be travelling back to the future of web development. That&#39;s right! Using only our brain and a simple text editor, we&#39;re going to concoct this beautiful website, leaving you with a strong foundation to build upon during your future web development adventures.<br> &lt;/p&gt;<br> &lt;p&gt;<br>  &lt;strong&gt;No prior web development knowledge is required&lt;/strong&gt; for completing this tutorial successfully. On the first day we&#39;ll explain what websites are made from. In the next 2 days we&#39;ll focus on building this website you&#39;re viewing now from scratch. <br> &lt;/p&gt;</pre><pre>&lt;!-- Button trigger modal --&gt;<br> &lt;button class=&quot;btn btn-primary btn-lg&quot;&gt;<br>  Show me some magic<br> &lt;/button&gt;<br>&lt;/section&gt;</pre><p><em>Add the following CSS snippet to your “base.css” file:</em></p><pre>h2 {<br> margin: 70px 0 20px;</pre><pre>font-size: 35px;<br> font-weight: 700;<br>}</pre><pre>p {<br> margin-bottom: 20px;<br>}</pre><pre>h2 + p {<br> font-size: 20px;<br> font-weight: 700;<br>}</pre><pre>p + button {<br> margin-top: 15px;<br>}</pre><pre>strong {<br> font-weight: 700;<br>}</pre><p>Note that the CSS selector h2 + p targets any paragraph element that’s directly preceded by a h2 header element, just as the p + button selector targets any button element that is directly preceded by a paragraph.</p><p>Not too shabby. But the font doesn’t look quite right, now does it? When you take a close look at our <a href="https://www.fredericaerts.com/external/developer-in-3-days/">example website</a>, you’ll notice that there are two different font families in play. Paragraphs are presented in one font family, and all other text in another. It’s becoming very clear now that the font used throughout our website is not matching those at all. The time has come to specify the appropriate fonts in our CSS. Doing this, we have to take into account that browsers can only actually use fonts that are available to them. It is therefore important that we also specify a fallback font whose presence is safe to assume on any computer. The obvious place to add these font family declarations is our “base.css” file. Add the following CSS declaration to the CSS rule for paragraphs: font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;. The browser will now go through the comma-separated font family list from left to right, applying the first font it finds on your computer to all paragraphs in your website. Even when it has to fallback to Arial, it still looks ok! And with that, our paragraphs are covered. We can now easily specify a font for all other text by targeting the body element. All nested elements will inherit this font setting, except for paragraphs that indeed overwrite it with a setting of their own. Let&#39;s use &quot;Oswald&quot; as our default font:</p><p><em>Specify a default font for your website by adding the following CSS rule to your “base.css” file:</em></p><pre>body {<br> font-family: &#39;Oswald&#39;, sans-serif;<br>}</pre><p>There are not a lot of fallback fonts specified here, and there are not a lot of computers that support “Oswald” either! But don’t you worry, cause with the help of <a href="https://www.google.com/fonts">google fonts</a>, we’re going to instruct the browser to download “Oswald” for us. You can do this by adding the following line to the &lt;head&gt; in your &quot;index.html&quot;: &lt;link href=&#39;https://fonts.googleapis.com/css?family=Oswald:400,700&quot; rel=&#39;stylesheet&quot; type=‘text/css’&gt;. Our website requires two font-weight variations (400 which is the default &amp; 700) from &quot;Oswald&quot;, and you can derive from this link that the browser is instructed to download both. Moving on…</p><h3>Devices image</h3><p>Since we can follow exactly the same protocol here as we did for the hero image, we can be brief about this section. Download the image <a href="https://www.fredericaerts.com/external/developer-in-3-days/images/devices.jpg">here</a>, put it in your images folder under the name “devices.jpg”, and add the following line to the &lt;body&gt; of your &quot;index.html&quot; file: &lt;img class=&quot;image-wide&quot; src=&quot;images/devices.jpg&quot;&gt;. The only question that remains is which CSS file to add the accompanying CSS rules to. Surely, this section is not a component, since it consists of one HTML element only. Neither is it generic enough to style on tag level in our &quot;base.css&quot;. We’ll thus put its styling in &quot;helper-classes.css&quot;, a file made especially for targeting specific component-independent classes. Hah! And in my opinion, we should also remove the h2 + p { … } CSS rule from our &quot;base.css&quot; file, and target an intro-text class in the &quot;helper-classes.css&quot; instead. Do you agree? Anyway, here’s the CSS for our &quot;devices image&quot; section:</p><p><em>Add the following CSS to your “helper-classes.css” file:</em></p><pre>.image-wide {<br> display: block;<br> width: 90%;<br> max-width: 1000px;<br> margin: 50px auto;<br>}</pre><p>Note that we’re using exactly the same CSS properties we used for styling the hero image. The properties used here differ only in their respective values, bringing about a much wider image on desktop computers.</p><h3>Tab section</h3><p>What we have here is a subtitle and intro paragraph whose styling we already covered, and then there’s a tab component whose styling we still need to insert in the “tabs.css” file. The tab component consists of three tab links and their three corresponding tab panes. Let’s have a look at the markup…</p><p><em>Add the tab section HTML to the body tag in your “index.html” file:</em></p><pre>&lt;section class=&quot;content-wrapper&quot;&gt;<br> &lt;h2&gt;Beginner program&lt;/h2&gt;<br> &lt;p class=&quot;intro-text&quot;&gt;<br>  Here&#39;s what you&#39;ll learn in the next 3 days.<br> &lt;/p&gt;<br> &lt;nav class=&quot;tab-links&quot;&gt;<br>  &lt;a href=&quot;#tab1&quot; class=&quot;tab-links-item active&quot;&gt;Day 1&lt;/a&gt;<br>  &lt;a href=&quot;#tab2&quot; class=&quot;tab-links-item&quot;&gt;Day 2&lt;/a&gt;<br>  &lt;a href=&quot;#tab3&quot; class=&quot;tab-links-item&quot;&gt;Day 3&lt;/a&gt;<br> &lt;/nav&gt;<br> &lt;div class=&quot;tab-panes&quot;&gt;<br>  &lt;div class=&quot;tab-panes-item active&quot; id=&quot;tab1&quot;&gt;<br>   &lt;h3&gt;What websites are made from&lt;/h3&gt;<br>   &lt;p&gt;<br>    On the first day we&#39;ll take a helicopter view on what websites are made from. You&#39;ll learn that virtually all websites are built using three languages: HTML, CSS &amp;amp; JavaScript. You&#39;ll get introduced to all three of them. <br>   &lt;/p&gt;<br>   &lt;p&gt;<br>    After we&#39;ve set the broad strokes for what it takes to build a website, we&#39;ll introduce you to some indispensable tools for any professional web developer...<br>   &lt;/p&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div class=&quot;tab-panes-item&quot; id=&quot;tab2&quot;&gt;<br>   &lt;h3&gt;Structure &amp;amp; styling&lt;/h3&gt;<br>   &lt;p&gt;<br>    On day 2 we&#39;ll setup the structure for this website with HTML, while styling it with CSS into the full blown website you&#39;re watching now. You&#39;ll also learn how &lt;a href=&quot;<a href="http://getbootstrap.com/">http://getbootstrap.com/</a>&quot; target=&quot;_blank&quot;&gt;Bootstrap&lt;/a&gt; can turbo boost website development.<br>   &lt;/p&gt;<br>   &lt;p&gt;<br>    This will be the day you&#39;ll be amazed about how much of a web development talent you actually are !<br>   &lt;/p&gt;<br>  &lt;/div&gt;</pre><pre>&lt;div class=&quot;tab-panes-item&quot; id=&quot;tab3&quot;&gt;<br>   &lt;h3&gt;Adding behavior &amp;amp; going live&lt;/h3&gt;<br>   &lt;p&gt;<br>    Hey, you just touched the &#39;DAY 3&#39; tab above, and here you are reading about what you&#39;re going to learn on day 3. How did that happen? Well, we&#39;ll use JavaScript to add this functionality to our website. You&#39;ll also find out how &lt;a href=&quot;<a href="http://jquery.com/">http://jquery.com/</a>&quot; target=&quot;_blank&quot;&gt;jQuery&lt;/a&gt; can make your live easier when adding behavior to your website.<br>   &lt;/p&gt;<br>   &lt;p&gt;<br>    Finally, you&#39;ll learn how to setup a domain name and how to put your website on a server. With everything set &amp;amp; done, we&#39;ll put that twitter bird to work introducing your website to the world... <br>   &lt;/p&gt;<br>  &lt;/div&gt;<br> &lt;/div&gt;<br>&lt;/section&gt;</pre><p>There are two HTML tags here that we didn’t use before. First, there’s &lt;h3&gt;, which represents a subtitle one level lower than our &lt;h2&gt; subtitles. We’re going to style it in our &quot;base.css&quot; file.</p><p><em>Style the h3 subtitle in your “base.css” like so:</em></p><pre>h3 {<br> margin: 30px 0 20px;<br> font-size: 25px;<br>}</pre><p>The other HTML tag in our tab component we haven’t used before is the very generic &lt;div&gt; tag. It defines a <strong>div</strong>ision block element and is probably the most used HTML tag throughout the web. If I would have written this series a couple of years ago, there would be plenty more &lt;div&gt; tags in our website too. With the inception of HTML5, however, many semantically more appropriate tags like &lt;header&gt;, &lt;footer&gt;, &lt;nav&gt;, &lt;section&gt;, etc… were introduced, enabling us to write clearer and more descriptive code. With these new semantic tags, screen readers can also better examine the HTML document and create an improved experience for users. But don’t you get too hung up on semantics either. There’s nothing wrong with using &lt;div&gt; tags in your HTML. In our case, for us to properly layout the tab component with CSS, it’s absolutely required that we wrap the tab panes and their content in block elements. No meaningful HTML tag exists for this purpose, so the &lt;div&gt; tag is the way to go here.</p><p>Looking at our tab component in the browser, you can see that all three tab panes are displayed. What we want though, is that only one tab pane is visible, namely the one that’s decorated with a class name active. We can then use JavaScript to move this active class from one tab pane to another according to which tab link was clicked. For now, let’s just update our CSS so that only the first (active) pane is displayed. And while we’re at it, let’s add some padding to these tab panes as well…</p><p><em>Add the following CSS to your “tabs.css” file:</em></p><pre>.tab-panes-item {<br> display: none;<br> padding: 10px 20px;<br>}</pre><pre>.tab-panes-item.active {<br> display: block;<br>}</pre><p>For styling the tab links, we’ll need to tinker with their border properties. First of, there’s a bottom border on their tab-links wrapper element. Then there’s also a left, top, and right border on the active tab-links-item element, but apparently no bottom border. We thus need to hide the tab-links wrapper border below the active tab-links-item element. There are several ways to do it, but we are going to give the active tab link a white background and then move it down 1 pixel over the tab-links border. We’ll finish up the tab link styling by polishing of those top border corners with the border-radius property.</p><p><em>Style your tab links by adding this CSS to your “tabs.css” file:</em></p><pre>.tab-links {<br> margin-top: 40px;<br> <br> border-bottom: 1px solid #DDDDDD;<br>}</pre><pre>.tab-links-item {<br> display: inline-block;<br> padding: 10px 20px;</pre><pre>font-weight: 700;<br> text-transform: uppercase;<br>}</pre><pre>.tab-links-item.active {<br> position: relative;<br> top: 1px;</pre><pre>color: #FF0000;</pre><pre>background: #FFFFFF;</pre><pre>border-top: 1px solid #DDDDDD;<br> border-left: 1px solid #DDDDDD;<br> border-right: 1px solid #DDDDDD;<br> border-top-right-radius: 3px;<br> border-top-left-radius: 3px;<br>}</pre><p>We now have a tab component that’s seemingly forever stuck on the first tab. However, we’ve constructed the tabs in such a way that it requires minimum effort to switch between them. All it takes is to transfer the active class between tab elements. We can already do this manually in our code, but tomorrow we’ll write some JavaScript that will take care of this for us.</p><h3>Footer</h3><p>Phew, last component… So what do we have here? We have some centered text like we had in the hero. We also have a footnote on the bottom right of the footer. The footer will thus — contrary to the hero — require a content wrapper to position this footnote against. Here’s the markup:</p><p><em>Add the footer HTML to the body tag in your “index.html” file:</em></p><pre>&lt;footer class=&quot;footer&quot;&gt;<br> &lt;div class=&quot;content-wrapper&quot;&gt;<br>  made with &lt;span class=&quot;footer-heart fa fa-heart&quot;&gt;&lt;/span&gt; by &lt;a href=&quot;<a href="http://fredericaerts.com/">http://fredericaerts.com</a>&quot; target=&quot;_blank&quot;&gt;Frederic Aerts*&lt;/a&gt;<br>  &lt;span class=&quot;footer-footnote&quot;&gt;*replace with your name&lt;/span&gt;<br> &lt;/div&gt;<br>&lt;/footer&gt;</pre><p>The &lt;span&gt; tag is new to us. You can think of the &lt;span&gt; tag as the inline counterpart of the &lt;div&gt; tag. Its only purpose is to provide a hook to a part of inline content, so that we can for instance target it for styling purposes. The first &lt;span&gt; tag is used here as a hook for Font Awesome to insert a heart icon. The second is used to style (position and font-size) our footnote.</p><p>In order to position the footnote against the content wrapper, we’re going to have to set its position property to absolute. We can then use the left, right, top and bottom properties to position the footnote relative to its first containing element that has its position property set to a non-default value. In our case, it’s the content wrapper, and it will have its position property set to relative. The rest of the footer styling is self-evident for a pro like you, so let’s just insert it into the &quot;footer.css&quot; file.</p><p><em>Add the following CSS to your “footer.css” file:</em></p><pre>.footer {<br> margin-top: 50px;</pre><pre> text-align: center;</pre><pre> background: #EEEEEE;<br>}</pre><pre>.footer .content-wrapper {<br> position: relative;</pre><pre> padding: 40px 0;<br>}</pre><pre>.footer-heart {<br> color: red;<br>}</pre><pre>.footer-footnote {<br> position: absolute;<br> right: 0;<br> bottom: 5px;</pre><pre> font-size: 10px;<br>}</pre><p>With that, all content has been added to our website. And it’s looking great too! But before we call it a day, let’s give our website an ultra professional boost with two little tweaks.</p><h3>Finishing touches</h3><p>You’ve probably noticed the sticky header in our <a href="https://www.fredericaerts.com/external/developer-in-3-days/">example website</a>. Sticky headers enable quicker navigation, especially when dealing with long pages. It eliminates the requirement for a user to scroll back up to be navigated elsewhere. To achieve this effect, we’re going to set the position property of the header to fixed and then position it at the top of the page by setting its top property to zero. If you try only this, you’ll see weird stuff happening to the header. First, the header is no longer taking up the full width of the page, and second, the hero has jumped to the top of the page, so that it’s seemingly positioned under the header. Both these phenomena can be explained by the fact that the header has actually been taken out of the flow of the web page by the position: fixed; declaration. Its width is thus no longer determined by its parent element, and the hero is now the first element taking up space in the web page. We can fix these issues by respectively setting the &lt;header&gt;’s width explicitly to 100%, and inserting some padding to the top of the &lt;body&gt; element. Here’s the updated CSS rule for our header:</p><p><em>Update the header CSS rule in your “header.css” file like so:</em></p><pre>.header {<br> position: fixed;<br> top: 0;</pre><pre> width: 100%;</pre><pre> background: #FFFFFF;<br> box-shadow: 0 0 2px 3px #DDDDDD;</pre><pre> z-index: 999;<br>}</pre><p>Note that we’ve also set a white background to the header, so that the underlying elements don’t show through.</p><p>Now all that’s left for us to do is to push down the hero a bit. In your “base.css” file, update the CSS rule that targets the &lt;body&gt; tag with the padding-top: 60px; declaration, and done is done! Until you visit the website from a mobile device…</p><p>Ok, it’s time we had “the talk”. Resize your browser window so that it becomes smaller than 750px in width (not coincidentally the width of your content wrapper), and watch part of your website fall off screen. Ugh! This is how your mobile users would experience your website as it is. And since the use of mobile devices has exploded over the last couple of years, we definitely need to take action here! Cue “Responsive Web Design” (RWD). The goal of RWD is to build web pages that detect the visitor’s screen size and change the layout accordingly. In our case, we want to detect if our website is viewed on a screen smaller than 750px, and act upon it by changing the width of the content wrapper to a 100%. Or if we take the opposite approach — the mobile first approach — we want our content wrapper to be full-width, unless the screen size exceeds 749px, in which case we want it centered with a fixed width of 750px. Detecting screen sizes in CSS is made possible by so-called media queries. Let’s use one to fix our issue.</p><p><em>Replace the content of your “grid.css” file with the following:</em></p><pre>.content-wrapper {<br> width: 100%;<br> padding: 0 15px;<br>}<br>/*  Media query<br>    ========================== */<br><a href="http://twitter.com/media">@media</a> (min-width: 750px) {<br> .content-wrapper {<br>  width: 750px;<br>  margin-left: auto;<br>  margin-right: auto;<br> }<br>}</pre><p>In this piece of code, everything that’s wrapped within the @media (min-width: 750px) { } curly braces will only be executed in screens that are at least 750px in width. Our first CSS rule thus has effect on smaller devices only, making our content wrapper stretch to full screen width on them. We’ve also applied a 15px left and right padding, so that its content doesn’t touch the borders of the screen. Viewed on a large enough screen, the width property of the content wrapper gets overwritten to 750px, and its left and right margins are set to auto so that it is centered. Note that the padding property does not get overwritten, and thus still stands on larger devices too, which is totally fine.</p><p>And with that, our website has become fully responsive. All that’s left for us to do now is to add some JavaScript action to it, and publish it for the whole world to admire. Let’s do that tomorrow…</p><p><em>“How to become a web developer in 3 days” is a beginner-friendly series designed to help aspiring web developers get acquainted with the languages that make up a website.</em></p><p><strong><em>Explore the series:</em></strong></p><ul><li><a href="https://medium.com/@frederic_aerts/day-1-what-websites-are-made-of-2f572662db71"><em>Day 1: What websites are made of</em></a></li><li><a href="https://medium.com/@frederic_aerts/day-3-behavior-and-going-live-5d8d4a73afba"><em>Day 3: Behavior and going live</em></a></li></ul><p><em>Originally published at </em><a href="https://www.fredericaerts.com/external/writing/developer-in-3-days/structure-and-styling/"><em>www.fredericaerts.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2576c63f0258" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 1: What websites are made of]]></title>
            <link>https://frederic-aerts.medium.com/day-1-what-websites-are-made-of-2f572662db71?source=rss-659cdb6e22ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f572662db71</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Frederic Aerts]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 09:59:06 GMT</pubDate>
            <atom:updated>2020-11-26T01:54:01.317Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJtkfHoT_b9_jDs1x3A_2A.jpeg" /></figure><p><em>“How to become a web developer in 3 days” is a beginner-friendly series designed to help aspiring web developers get acquainted with the languages that make up a website.</em></p><p><strong><em>Explore the series:</em></strong></p><ul><li><a href="https://medium.com/@frederic_aerts/day-2-structure-and-styling-2576c63f0258"><em>Day 2: Structure and styling</em></a></li><li><a href="https://medium.com/@frederic_aerts/day-3-behavior-and-going-live-5d8d4a73afba"><em>Day 3: Behavior and going live</em></a></li></ul><h3>Day 1: What websites are made of</h3><blockquote><em>As to methods, there may be a million and then some, but principles are few. The man who grasps principles can successfully select his own methods. The man who tries methods, ignoring principles, is sure to have trouble.</em></blockquote><blockquote><em>— Ralph Waldo Emerson</em></blockquote><p><strong>I don’t have to tell you that the ability to build websites is an incredibly empowering skill. The idea of building things — especially things of your own design — that could potentially reach millions of people is an exhilarating one. When you get started with building your first website, it’s easy to get overwhelmed by all the information out there. Before you get caught in tutorial paralysis, let us get one thing straight: you don’t have to be a genius to build websites! What you do need, is to be determined. In the end, it’s all just a matter of breaking down problems into smaller problems, and then solving them one by one. So for this series, the problem we’ll solve is: how can we, without any prior knowledge in web development, build </strong><a href="https://www.fredericaerts.com/external/developer-in-3-days/"><strong>this website</strong></a><strong> in 3 days time. We’ll break this problem down into: getting acquainted with the languages that make up any website (day 1), laying down the structure and style for our website (day 2), and finally, adding interaction behavior and publishing it for the world to admire (day 3). When you’ve finished this series, you’re going to look like you have magical powers compared to everyone else. So let’s get started…</strong></p><h3>Browsers talk HTML</h3><p>When you visit a website, basically what happens is that your browser fetches an HTML file from a server and renders the information in this file for your eyes to see. Which HTML file gets fetched from which server depends on the url you’ve entered in your browser’s address bar. Thus, the first step to building a website is creating such an HTML file;</p><p><em>Open your text editor (notepad on Windows, textEdit on Mac), type </em><em>Hello world. This is my first website and save it as &quot;index.html&quot; (in textEdit, select the Format menu before saving and choose &quot;Make Plain Text”). Be sure to save it in the web page file format, which means it should have a .html extension and not the default .txt extension. Now, using your favorite browser (Internet Explorer, Safari, Chrome, Firefox…), choose &quot;Open file&quot; from the File menu and navigate to your &quot;index.html&quot; file. Select it and click Open, or even easier, just drag the &quot;index.html&quot; file in your browser window. Your browser should now say &quot;Hello world. This is my first website&quot;. Congratulations, you’ve created your first website!</em></p><p>You might not realize it yet, but you’ve just written some HTML (HyperText Markup Language). HTML is a human readable language that tells the browser all about the <strong>content</strong> and <strong>structure</strong> of the web page. In the website you’ve just built, “Hello world. This is my first website” is the content of the web page. Now, with the help of some HTML tags, let’s give the browser some cues about the structure and meaning of this content.</p><p><em>In your “index.html”, surround your existing text with HTML tags, like so: </em><em>&lt;h1&gt;Hello World&lt;/h1&gt;&lt;p&gt;This is my first website&lt;/p&gt;. Be sure to get the specific HTML tag syntax correct! The closing HTML tags have an additional forward slash in them. Now save your HTML file, refresh your browser and observe the transformation of the text in the browser.</em></p><p>As you can see, the HTML tags themselves are not visible in the browser. They are only present in your HTML file to give the browser cues on the meaning of the content inside these tags. In our example, the <strong>h1</strong> and <strong>p</strong> tag tell the browser that “Hello world” and “This is my first website” are to be treated as a <strong>h</strong>eader and a <strong>p</strong>aragraph, respectively. Besides h1 and p, many other HTML tags are available to describe the structure of a web page semantically. For most of these tags, browsers have built-in default rules on how to display their content. In our example, the header text is displayed bigger and bolder than regular text, a line break is enforced, and both the header and paragraph have been given top and bottom margins. However, you don’t have to settle for these default rules! You can enforce your own style and formatting rules with another human readable language called CSS.</p><p>Ok, so what we have so far is an html file with some markup. Does that make it a valid web page? Not quite. Before we’re going to add style to our page, let’s get the proper HTML template in place that is used for any professional web page.</p><p><em>Replace the content in your current “index.html” file with the following:</em></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;  <br>  &lt;head&gt;<br>    &lt;title&gt;My first website&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Hello World&lt;/h1&gt;<br>    &lt;p&gt;This is my first website&lt;/p&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Note that we’re nesting HTML tags here, e.g. the <strong>title</strong> tag is nested within the <strong>head</strong> tag. We’re also using line-breaks and indentation to clean up our code, which is a crucial thing to do if you want to avoid spending hours on finding for example a missing closing HTML tag. This formatting of your code will not be reflected in your web page. Line-breaks and indentations can only be enforced by HTML tags and their corresponding CSS rules.</p><p>After saving your HTML file and refreshing your browser (this is the last time I’ll tell you to save your HTML file and refresh your browser. You should do this with every update in your HTML file), you’ll notice that not a lot has changed in your web page. What are these extra tags for then? Let’s look at them one by one:</p><ul><li>&lt;!DOCTYPE html&gt;<br> The &lt;!DOCTYPE&gt; declaration must be the very first thing in your HTML document. It is an instruction to the web browser about what version of HTML the page is written in. We’re using the most simplified &lt;!DOCTYPE&gt; declaration here, which coincidentally is the most correct one too, according to the latest HTML specification (HTML5). Who said building websites should be complicated?</li><li>&lt;html&gt;&lt;/html&gt;<br> This tells the browser the content of the file is HTML. All your HTML must be surrounded by this tag. Its only direct children are the <strong>head</strong> and <strong>body</strong> tags.</li><li>&lt;head&gt;&lt;/head&gt;<br> The head contains information about your web page, like its title. Later on, this will also be the place where we’ll give the browser instructions on where to find the CSS that styles our web page.</li><li>&lt;title&gt;&lt;/title&gt;<br> Unsurprisingly, the title tag contains the title of your web page. It usually appears at the top of your browser window. It’s also important information for search engines like google.</li><li>&lt;body&gt;&lt;/body&gt;<br> The body contains all the content and structure of your web page —the parts of the web page that you see in the browser.</li></ul><h3>Adding style</h3><p>Now that we have this formal stuff out of the way, it’s time to tell the browser where to find the CSS (Cascading StyleSheet) that styles our web page. The logical place to add this information is in the head tag, and that’s exactly where we’ll put it.</p><pre>&lt;head&gt;<br>  &lt;title&gt;My first website&lt;/title&gt;<br>  &lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;<br>&lt;/head&gt;</pre><p>Note that the link tag has no closing tag. It’s what we call a self-enclosing HTML tag. There’s no reason for it to have a closing tag since there’s no content to be contained. Like any HTML tag though (more on this later), the link tag can contain information about itself in its attributes. Our link tag uses the attributes <strong>href</strong> and <strong>rel</strong> to explain to the browser that it should fetch a file named style.css and use it as the stylesheet for our web page. Let’s create that CSS file:</p><p><em>In your text editor, create a new file, type </em><em>h1{color:red;} and save it as &quot;style.css&quot; (in textEdit again, select the Format menu before saving and choose &quot;Make Plain Text”) in the same directory as your &quot;index.html&quot; file. Be sure to save it in stylesheet format, which means it should have a .css extension and not the default .txt extension. Now, refresh your browser. The header &quot;Hello world&quot; has a red color now.</em></p><p>It’s quite possible that the header in your browser doesn’t have a red color yet. It’s possible that creating your “index.html” and getting it to display as a web page in your browser wasn’t smooth sailing either. If so, than I respect you for still hanging in there. And let me seize this opportunity to share with you this brutal truth: <strong>the beginning stages of becoming a web developer can really suck sometimes</strong>. You’ll feel overwhelmed, you’ll feel like throwing your computer out of the window, and you’ll feel like there’s no way you’re ever going to learn this shit and be good enough. My advice would be to keep your cool and approach these obstacles as opportunities to learn. These are the moments when the wheat gets separated from the chaff, and it’s for you to decide where you stand. It also helps to know there’s a huge developer community out there that faced similar problems, and were kind enough to share their solutions on a multitude of blogs, forums, Q&amp;A sites, … across the internet. So whenever you run out of ideas for solving a problem, just google it! To get back to our my-header-isn’t-red problem, here are some possible solutions:</p><ul><li>Double check special characters in your HTML and CSS files. E.g. in h1{color:red;} Are you using colons and semicolons correctly?</li><li>Did you save the updates in your HTML and CSS files? Did you refresh your browser?</li><li>Double check the value of the href attribute in your link tag. Does it match your css file name?</li><li>Check the location of your CSS file on your computer. It should be located in the same directory as your “index.html” file.</li><li>textEdit users on Mac: in the Edit menu of your “index.html” file, select “Substitutions”, uncheck “Smart Quotes” and rewrite your double quotation marks around your attribute values (I had to google this problem myself).</li><li>etc…</li></ul><p>Back on track? Ok then, let’s take a closer look at what we’ve got so far. Firstly, when a browser opens our HTML file, it processes it from top to bottom. It encounters a link tag which references our CSS file as the stylesheet for our web page. The browser retrieves this CSS file and processes it, saving all the CSS rules within it. The browser then processes the rest of our HTML file, applying its CSS rules to the respective HTML tags. Looking at our CSS rule h1{color:red;}, its meaning is quite self-explanatory. In order for the browser to understand it, though, the syntax has to be one hundred percent correct. Luckily for us, it’s always the same pattern: <strong>CSS selector</strong> (in our case h1) followed by curly braces that contain one or more <strong>CSS declarations</strong> (in our case color:red;). Each CSS declaration includes a <strong>CSS property</strong> (in our case color) and a corresponding value (in our case red), separated by a colon. All CSS declarations end with a semicolon. Easy as pie…</p><p>Needless to say, there’s a huge amount of CSS properties available for styling our web page. We could go through the list, but that would be pointless. Instead, we’ll conjure them up as needed while building our website. For now, let’s focus on CSS selectors.</p><p>As it stands now, if we’d have multiple h1 headers in our web page, they would all be colored red. Now suppose we want only a specific type of header colored red, namely the headers marked as “highlighted”. Seems like a reasonable requirement, right? Are we supposed to invent a new HTML tag for highlighted h1 headers now? No way, man! That would lead us to an html tag soup we can’t possibly expect the browser to make sense of. Instead, we’ll decorate HTML tags with attributes, and target these attributes using specific CSS selectors. The attribute predominantly used as a hook for CSS selectors is the class attribute. Let’s look at an example:</p><p><em>In your “index.html” file, add a class to the current h1 header like so: </em><em>&lt;h1 class=“highlighted”&gt;Hello world&lt;/h1&gt;. In your &quot;style.css&quot; file, target this header by replacing the current CSS rule with </em><em>.highlighted {color: red;}.</em></p><p>Note the dot before the class name in our new CSS rule? That’s special CSS syntax reserved for targeting elements (from now on we’ll refer to HTML tags with their content as “elements”) with the respective class attribute. In other words, our CSS selector is now targeting all elements with a class name “highlighted”. If you’d add this class to our paragraph element, it would be red as well. Give it a try! Isn’t it wonderful… Note that although the choice of class name is entirely up to you, it’s highly recommended to keep them semantically correct.</p><p>Now what if we added a second rule to our CSS file h1{color:brown;}? Will our header color brown or red? Indeed, we now have two categories of CSS selectors (type selector vs. class selector) in our CSS file, both targeting our h1 header. And by the way, are there any other categories of CSS selectors I should know of? Yes sir, there are! And you’d probably like to know that you can combine multiple CSS selectors too, like for instance h1.highlighted{} targeting only h1 headers with a class highlighted. And you should also know that… Hold it right there! This is neither the time nor place to learn about complex CSS selector patterns. Keeping our CSS code simple is not only convenient for us at this point, it’s also best practice. Let’s focus on what we need to build our website, and what we need is a notion of the concept CSS specificity. Here’s a definition:</p><blockquote>CSS specificity is the means by which a browser decides which CSS property values are the most relevant to an element and therefore will be applied. CSS specificity is based on the matching rules which are composed of CSS selectors of different sorts.</blockquote><p>In other words, if we have multiple CSS selectors targeting the same element, the most specific CSS selector pattern will determine the value of their shared CSS properties. The question that follows naturally is: what makes one CSS selector more specific than another? Well, there’s an elaborate set of rules for determining a selector’s specificity… which we’re going to ignore completely. For now, we’re going to adhere to one principle only, which is: use your common sense. I hope we can agree that this principle implies that class selectors are more specific than tag selectors, and that selector specificity increases with its complexity (e.g. h1.highlighted is a more complex selector than .highlighted, and thus is more specific). If we’d have multiple selectors with equal specificity, the selector closest to the bottom of our CSS file wins. Let’s keep in mind that if you have a CSS rule targeting a certain element, but its style properties aren’t applied as expected, CSS specificity is probably the cause.</p><p>Let’s look at some examples of CSS selectors, ordered by increasing specificity. Grasping these will suffice for now.</p><ul><li><strong>Tag selector</strong><br> example: h1{}<br> Targets h1 elements</li><li><strong>Class selector</strong><br> example: .highlighted{}<br> Targets elements with a class name &quot;highlighted”</li><li><strong>Multiple selectors separated by a space</strong><br> example: body .highlighted {}<br> Targets elements with a class name &quot;highlighted&quot;, nested within the body tag</li><li><strong>Multiple selectors without a space between them</strong><br> example: .highlighted.active {}<br> Targets elements that have both a &quot;highlighted&quot; and an &quot;active&quot; class. Yep, HTML tags can have multiple classes, like so: &lt;h1 class=“highlighted active”&gt;Hello world&lt;/h1&gt;</li><li><strong>Pseudo-class selector</strong><br> example: .highlighted:hover {}<br> Targets elements with a class name &quot;highlighted&quot; that the user mouses over</li></ul><p>Now don’t get me wrong. If you want people to take you seriously as a web developer, you’d better understand CSS specificity. Complex websites lead to complex CSS selectors, which in turn lead to hair loss if you don’t master CSS specificity. The website we’re going to build however is quite simple, enabling us to write simple CSS code and thus avoiding complex CSS selectors.</p><p><em>Et voila</em>, that’s all you need to know about CSS for now. I agree that the styles we’ve applied to our header and paragraph so far have been all but spectacular, so let’s conclude this section by showing off what CSS is really capable of:</p><p><em>Replace the current CSS rules in our CSS file with the following;</em></p><pre><a href="http://twitter.com/import">@import</a> url(https://medium.com/%3Ca%20href=%22/service/http://fonts.googleapis.com/css?family=Lobster%22%3Ehttp://fonts.googleapis.com/css?family=Lobster%3C/a%3E);</pre><pre>body {<br> font-family: &#39;Lobster&#39;, cursive;<br> <br> background:#444;</pre><pre> text-align: center;<br>}</pre><pre>h1 {<br>  margin-top: 50px;</pre><pre> font-size: 50px;<br> color: #222;<br> text-shadow: 0px 2px 1px #777; <br> text-shadow: 0px 2px 1px #777, 0px -4px 2px #000;<br>}</pre><pre>p {<br> width: 40%;<br> margin: auto;<br> padding: 30px;<br> <br> font-size: 20px;<br> color: #fff;<br> <br> border-top: 1px solid #fff;<br> border-bottom: 1px solid #fff;<br>}</pre><p>Lo and behold, this little piece of self-explanatory CSS code has transformed our website into a true work of art! Don’t worry if you don’t grasp all the details yet, but worth noting is the proper use of indentation and grouping of related CSS properties for better readability. Also note that elements can inherit some CSS properties from their parent elements, illustrated here by the <strong>font-family</strong> and <strong>text-align</strong> properties in our h1 and p elements.</p><h3>Adding behavior</h3><p>With HTML and CSS under your belt, you have everything at hand to build stunningly beautiful websites. If that suits your needs, well then you can go right ahead and skip this section. If you want your websites to come alive, however, you’re going to have to get acquainted with JavaScript. Where HTML and CSS are markup languages, JavaScript is a programming language, which is another ballgame entirely. In our website, we’re going to harness the power of Javascript to implement tab functionality and for prompting our bootstrap modal when the “Show me some magic” button is clicked.</p><p>The purpose of this series in respect to JavaScript is not to teach you the ins and outs of this programming language, but rather to give you a feel for how JavaScript can add behavior to websites. This by itself will enable you to do add a multitude of functionalities to your website. How’s that, you ask? By incorporating ready-made code snippets from other developers into your website, I answer. No need to reinvent the wheel, right? If you’d like to eat a pie, you can either make one yourself or you can get it in a bakery. We’re gonna get our pie in a bakery. If you want to make your own pie, I’d suggest you open up a book on the subject.</p><p>One thing you need to understand is that, since we’re writing JavaScript that is to be executed in a browser environment, we are able to interact with objects provided to us by this browser. Interaction with these ‘host objects’ enables us to control the behavior of our browser. Let’s create a JavaScript file that will prompt our browser to display a popup message box:</p><p><em>In your text editor, create a new file, type </em><em>window.alert(‘Hello, I’m a popup’); and save it as &quot;script.js&quot; in the same directory as your &quot;index.html&quot; file. Be sure to save it in JavaScript format, which means it should have a .js extension instead of the default .txt extension. Now, instruct the browser to fetch this file by adding a script tag in the head of your &quot;index.html&quot; like so:</em></p><pre>&lt;head&gt;<br> &lt;title&gt;My first website&lt;/title&gt;<br> &lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;<br> &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/head&gt;</pre><p>Note that although no content is enclosed by the script tag, you should not omit the closing tag here. Let’s just accept this nuance of HTML grammar with the stoicism of a cow standing in the rain. Now refresh your browser. A popup is prompted by the browser on pageload.</p><p>The main host object that’s provided to us by the browser is the window object. In our example, we’re invoking the alert() method on it, thereby sending the message &quot;Hello, I’m a popup&quot; to the browser internals, which handle it by drawing and displaying the message box. Now unless you’re out to create an unfortunate game of whack-a-mole, we’d better dig deeper into the window object.</p><p>The most commonly used property of the window object is the document object, which serves as an entry point into the web page’s content, namely the Document Object Model (DOM) tree. The DOM tree for your current website should look familiar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*NvVMEKw1rBv1M7cK.jpg" /></figure><p>This DOM tree is created by the browser upon pageload, and is based on the HTML file we provided. Via the window.document object, we can now iterate over this DOM tree, access and manipulate our existing HTML elements, and even create or delete HTML elements on the fly. An important gotcha we have to take into account is that the browser is only able to construct the DOM after it has processed our HTML file in its entirety. Execution of our JavaScript file can thus start before DOM availability, resulting in errors when it’s trying to interact with our as of yet inexistent DOM. Luckily for us, the browser keeps us in the know on the myriad of events occurring, one of which is DOM content loading. DOM manipulating code should be wrapped in a function that’s executed only when this ‘DOMContentLoaded’ event is triggered. Let’s illustrate this:</p><p><em>Copy the following piece of code in our “script.js” file;</em></p><pre>var paragraphElement = window.document.createElement(&quot;p&quot;);<br>var paragraphText = window.document.createTextNode(&quot;This paragraph was created by JavaScript&quot;);<br>paragraphElement.appendChild(paragraphText);</pre><pre>window.document.addEventListener(&#39;DOMContentLoaded&#39;, function() {<br> window.document.querySelector(&#39;body&#39;).appendChild(paragraphElement);<br>});</pre><p>Read through this code line by line. Can you figure what will happen to your website when you refresh your browser? In the first three lines of code, we are creating a brand new paragraph element. Since this is not dependent on our DOM tree, we don’t have to wait for the ‘DOMContentLoaded’ event to execute this code. Once the DOM is loaded, we’re selecting the body element from it, and appending our new paragraph element to it. As a result, you’ll see a new paragraph added to the bottom of your website. This paragraph element was not declared statically in your HTML file, but added dynamically from your JavaScript file. Not impressed? Then imagine what you can achieve by tapping into click events to toggle classes (and thus CSS styling) on HTML elements. Coincidentally, that’s the approach we’ll use to implement tab functionality for the website we’re building in the coming days.</p><h3>The right tools for the job</h3><p>If you don’t use the right tools for the job, you’re apt to find something you didn’t expect and get discouraged. So far, we’ve been using our default text editor (notepad on Windows, textEdit on Mac) to code our websites. Text editors like these are great for building your very first “Hello world” website, as it drives home the point that virtually anyone is able to build websites. However, they are very basic in their functionality. If you’re writing a body of formatted text, you’re not likely to use this simple editor, but rather a specialized editor like Microsoft Word or Google Docs. Likewise, you should use a specialized editor for building websites. Examples of such editors are Coda, TextMate, Vim… I use <a href="https://www.sublimetext.com/">Sublime Text</a>, which I hereby recommend. Get it now! The benefits will be self evident immediately.</p><p>Another indispensable set of tools for any web developer is most likely already built in in your browser, though some browsers require more action than others to open them. In most browsers, right clicking on a website and selecting “inspect element” will do. If this is not an option for you, I suggest googling for instructions on how to open these developer tools in your specific browser. Browser developer tools enable you to take a look at your code from a browser’s perspective, which evidently can be very helpful when testing and debugging your code. There’s an enormous amount of functionality in these tools, aimed specifically at facilitating the process of building websites. I’ll leave you to discover them for yourself.</p><p><em>“How to become a web developer in 3 days” is a beginner-friendly series designed to help aspiring web developers get acquainted with the languages that make up a website.</em></p><p><strong><em>Explore the series:</em></strong></p><ul><li><a href="https://medium.com/@frederic_aerts/day-2-structure-and-styling-2576c63f0258"><em>Day 2: Structure and styling</em></a></li><li><a href="https://medium.com/@frederic_aerts/day-3-behavior-and-going-live-5d8d4a73afba"><em>Day 3: Behavior and going live</em></a></li></ul><p><em>Originally published at </em><a href="https://www.fredericaerts.com/external/writing/developer-in-3-days/what-websites-are-made-of/"><em>www.fredericaerts.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f572662db71" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>