 
    
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>understanding Archives - Complete, Concrete, Concise</title>
	<atom:link href="https://complete-concrete-concise.com/tag/understanding/feed/" rel="self" type="application/rss+xml" />
	<link>https://complete-concrete-concise.com/tag/understanding/</link>
	<description>Practical Information Without The Bloat</description>
	<lastBuildDate>Sat, 18 Mar 2023 19:50:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>CSS Specificity &#8211; Advanced CSS Selectors &#8211; Part 2</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-specificity-advanced-css-selectors-part-2/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Fri, 19 Apr 2019 14:57:44 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css selectors]]></category>
		<category><![CDATA[css specificity]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3822</guid>

					<description><![CDATA[<p>Learn to be more specific in selecting elements for styling and how to calculate the specificity of CSS selectors.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-specificity-advanced-css-selectors-part-2/">CSS Specificity &#8211; Advanced CSS Selectors &#8211; Part 2</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
<p>Understanding CSS <em>specificity</em> will help you understand how rules are applied to the elements on your page and allow you greater control over how your page is styled.</p>
</div>
<h2 id="contents">Contents</h2>
<ol class="incremental" type="1">
<li><a href="#getting-specific">Getting Specific</a></li>
<li><a href="#calculating-specificity">Calculating Specificity</a></li>
<li><a href="#rules-for-creating-specific-selectors">Rules for Creating Specific Selectors</a></li>
<li><a href="#final-words">Final Words</a></li>
<li><a href="#references">References</a></li>
</ol>
<h2 id="getting-specific">Getting Specific</h2>
<p>You’ve seen that you can apply multiple styles to an HTML element like this:</p>
<div class="sourceCode" id="cb1">
<pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">&quot;first&quot;</span><span class="ot"> class=</span><span class="st">&quot;important box&quot;</span><span class="kw">&gt;</span></a></code></pre>
</div>
<p>And you can create individual styles for various elements on the page:</p>
<div class="sourceCode" id="cb2">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb2-1" title="1">p {</a>
<a class="sourceLine" id="cb2-2" title="2">  <span class="kw">background-color</span>: <span class="cn">aliceblue</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-3" title="3">}</a>
<a class="sourceLine" id="cb2-4" title="4"></a>
<a class="sourceLine" id="cb2-5" title="5"><span class="pp">#first</span> {</a>
<a class="sourceLine" id="cb2-6" title="6">  <span class="kw">background-color</span>: <span class="cn">darkgray</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-7" title="7">  <span class="kw">color</span>: <span class="cn">yellow</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-8" title="8">}</a>
<a class="sourceLine" id="cb2-9" title="9"></a>
<a class="sourceLine" id="cb2-10" title="10"><span class="fu">.important</span> {</a>
<a class="sourceLine" id="cb2-11" title="11">  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-12" title="12">  <span class="kw">background-color</span>: <span class="cn">red</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-13" title="13">  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-14" title="14">  <span class="kw">border</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-15" title="15">}</a>
<a class="sourceLine" id="cb2-16" title="16"></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="fu">.box</span> {</a>
<a class="sourceLine" id="cb2-18" title="18">  <span class="kw">border</span>: <span class="dv">1</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb2-19" title="19">}</a></code></pre>
</div>
<p>A number of rules style the same CSS properties &#8211; <span class="css-property">background-color</span> and <span class="css-property">color</span> &#8211; and final result depends on:</p>
<ol class="incremental" type="1">
<li>the priority (or significance) of the selectors</li>
<li>for selectors with the same priority, the last defined property takes priority.</li>
</ol>
<p>Which means that the final style rule looks like this</p>
<div class="sourceCode" id="cb3">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb3-1" title="1">{</a>
<a class="sourceLine" id="cb3-2" title="2">  <span class="co">/* ID styles have highest priority */</span></a>
<a class="sourceLine" id="cb3-3" title="3">  <span class="kw">background-color</span>: <span class="cn">darkgray</span><span class="op">;</span></a>
<a class="sourceLine" id="cb3-4" title="4">  <span class="kw">color</span>: <span class="cn">yellow</span><span class="op">;</span></a>
<a class="sourceLine" id="cb3-5" title="5">  <span class="co">/* font-size is only specified in .important,</span></a>
<a class="sourceLine" id="cb3-6" title="6"><span class="co">     so it is applied */</span></a>
<a class="sourceLine" id="cb3-7" title="7">  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span></a>
<a class="sourceLine" id="cb3-8" title="8">  <span class="co">/* border in .box is defined after border was</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="co">     defined in .important, so it gets applied */</span></a>
<a class="sourceLine" id="cb3-10" title="10">  <span class="kw">border</span>: <span class="dv">1</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb3-11" title="11">}</a></code></pre>
</div>
<p>This can seem haphazard and you might like to have better control over your CSS style rules &#8211; especially if later declarations can override earlier declarations.</p>
<p>We can overcome this by being more specific with our styling rules:</p>
<div class="sourceCode" id="cb4">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb4-1" title="1"><span class="co">/*</span></a>
<a class="sourceLine" id="cb4-2" title="2"><span class="co">  Apply this style to any element which has</span></a>
<a class="sourceLine" id="cb4-3" title="3"><span class="co">  id=&quot;first&quot; AND class=&quot;important&quot;</span></a>
<a class="sourceLine" id="cb4-4" title="4"><span class="co">*/</span></a>
<a class="sourceLine" id="cb4-5" title="5"><span class="pp">#first</span><span class="fu">.important</span> {</a>
<a class="sourceLine" id="cb4-6" title="6">  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span></a>
<a class="sourceLine" id="cb4-7" title="7">  <span class="kw">background-color</span>: <span class="cn">red</span><span class="op">;</span></a>
<a class="sourceLine" id="cb4-8" title="8">  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb4-9" title="9">}</a></code></pre>
</div>
<p>We can get even more specific with the following:</p>
<div class="sourceCode" id="cb5">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb5-1" title="1"><span class="co">/*</span></a>
<a class="sourceLine" id="cb5-2" title="2"><span class="co">  Apply this style to any &lt;p&gt; element which has</span></a>
<a class="sourceLine" id="cb5-3" title="3"><span class="co">  id=&quot;first&quot; AND class=&quot;important&quot;</span></a>
<a class="sourceLine" id="cb5-4" title="4"><span class="co">*/</span></a>
<a class="sourceLine" id="cb5-5" title="5">p<span class="pp">#first</span><span class="fu">.important</span> {</a>
<a class="sourceLine" id="cb5-6" title="6">  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span></a>
<a class="sourceLine" id="cb5-7" title="7">  <span class="kw">background-color</span>: <span class="cn">red</span><span class="op">;</span></a>
<a class="sourceLine" id="cb5-8" title="8">  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb5-9" title="9">}</a></code></pre>
</div>
<p>However, if you created the following rule:</p>
<div class="sourceCode" id="cb6">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb6-1" title="1"><span class="co">/*</span></a>
<a class="sourceLine" id="cb6-2" title="2"><span class="co">  Apply this style to any &lt;p&gt; element which has</span></a>
<a class="sourceLine" id="cb6-3" title="3"><span class="co">  a class=&quot;important&quot;</span></a>
<a class="sourceLine" id="cb6-4" title="4"><span class="co">*/</span></a>
<a class="sourceLine" id="cb6-5" title="5">p<span class="fu">.important</span> {</a>
<a class="sourceLine" id="cb6-6" title="6">  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span></a>
<a class="sourceLine" id="cb6-7" title="7">  <span class="kw">background-color</span>: <span class="cn">red</span><span class="op">;</span></a>
<a class="sourceLine" id="cb6-8" title="8">  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span></a>
<a class="sourceLine" id="cb6-9" title="9">}</a></code></pre>
</div>
<p>And you applied it to the following code:</p>
<div class="sourceCode" id="cb7">
<pre class="sourceCode html"><code class="sourceCode html"><a class="sourceLine" id="cb7-1" title="1"><span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">&quot;first&quot;</span><span class="ot"> class=</span><span class="st">&quot;important box&quot;</span><span class="kw">&gt;</span></a></code></pre>
</div>
<p>You would find that the styles of <span class="css-id">#first</span> would take priority over the styles in <span class="css-class">p.important</span> despite <span class="css-class">p.important</span> appearing to be more specific &#8211; after all, it specifies <strong>two</strong> selectors (&lt;element&gt; and .class) over the <strong>single</strong> ID selector.</p>
<p>This is because the <strong>significance</strong> of a rule depends on the <em>specificity</em> of the selector. CSS specificity is calculated using a few straightforward rules.</p>
<h2 id="calculating-specificity">Calculating Specificity</h2>
<p>Specificity is calculated as a string of three values<a href="#fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a>. Many resources and tutorials show it as a single number like 000 or 130. Some tutorials show it in the form 0-0-0 or 1-3-0 &#8211; which is a better representation. I will use the following representation: 0:0:0 or 1:3:0.</p>
<p>The <em>specificity</em> number indicates the total counts of various basic selectors. The universal selector always has a <em>specificity</em> of 0:0:0 &#8211; so any selector with a higher <em>specificity</em> will trump it. As with normal numbers, the leftmost digits are more significant than the rightmost digits. Consider the ranking of the following specificities:</p>
<ul class="incremental">
<li>0:0:1 &gt; 0:0:0</li>
<li>0:2:0 &gt; 0:1:0</li>
<li>0:2:1 &gt; 0:1:6</li>
<li>0:2:5 &gt; 0:2:4</li>
<li>1:2:3 &gt; 0:12:7</li>
</ul>
<p>The <em>specificity</em> number is calculated as the total number of CSS specifiers used for that style rule. The totals are arranged in the following manner:</p>
<table style="border:1px solid black;margin: auto;">
<tr>
<td style="border:1px solid black;padding:1.5em;">
IDs
</td>
<td style="border:1px solid black;padding:1.5em;">
.classes and [attributes]
</td>
<td style="border:1px solid black;padding:1.5em;">
&lt;elements&gt;
</td>
</tr>
</table>
<p>Consider the specificity of the following selectors:</p>
<div class="sourceCode" id="cb8">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb8-1" title="1"><span class="op">*</span> {</a>
<a class="sourceLine" id="cb8-2" title="2">  <span class="co">/* specificity = 0:0:0 */</span>  </a>
<a class="sourceLine" id="cb8-3" title="3">}</a>
<a class="sourceLine" id="cb8-4" title="4"></a>
<a class="sourceLine" id="cb8-5" title="5">p {</a>
<a class="sourceLine" id="cb8-6" title="6">  <span class="co">/* specificity = 0:0:1 */</span>  </a>
<a class="sourceLine" id="cb8-7" title="7">}</a>
<a class="sourceLine" id="cb8-8" title="8"></a>
<a class="sourceLine" id="cb8-9" title="9"><span class="fu">.class</span> {</a>
<a class="sourceLine" id="cb8-10" title="10">  <span class="co">/* specificity = 0:1:0 */</span>  </a>
<a class="sourceLine" id="cb8-11" title="11">}</a>
<a class="sourceLine" id="cb8-12" title="12"></a>
<a class="sourceLine" id="cb8-13" title="13"><span class="ex">[attribute]</span> {</a>
<a class="sourceLine" id="cb8-14" title="14">  <span class="co">/* specificity = 0:1:0 */</span>    </a>
<a class="sourceLine" id="cb8-15" title="15">}</a>
<a class="sourceLine" id="cb8-16" title="16"></a>
<a class="sourceLine" id="cb8-17" title="17"><span class="pp">#id</span> {</a>
<a class="sourceLine" id="cb8-18" title="18">  <span class="co">/* specificity = 1:0:0 */</span>  </a>
<a class="sourceLine" id="cb8-19" title="19">}</a>
<a class="sourceLine" id="cb8-20" title="20"></a>
<a class="sourceLine" id="cb8-21" title="21">p<span class="fu">.class</span> {</a>
<a class="sourceLine" id="cb8-22" title="22">  <span class="co">/* specificity = 0:1:1 */</span></a>
<a class="sourceLine" id="cb8-23" title="23">}</a>
<a class="sourceLine" id="cb8-24" title="24"></a>
<a class="sourceLine" id="cb8-25" title="25">ol<span class="ex">[reversed]</span> {</a>
<a class="sourceLine" id="cb8-26" title="26">  <span class="co">/* specificity = 0:1:1 */</span></a>
<a class="sourceLine" id="cb8-27" title="27">}</a>
<a class="sourceLine" id="cb8-28" title="28"></a>
<a class="sourceLine" id="cb8-29" title="29">p<span class="pp">#id</span><span class="fu">.class</span> {</a>
<a class="sourceLine" id="cb8-30" title="30">  <span class="co">/* specificity = 1:1:1 */</span></a>
<a class="sourceLine" id="cb8-31" title="31">}</a>
<a class="sourceLine" id="cb8-32" title="32"></a>
<a class="sourceLine" id="cb8-33" title="33">p<span class="pp">#id</span><span class="fu">.class</span><span class="ex">[attribute]</span> {</a>
<a class="sourceLine" id="cb8-34" title="34">  <span class="co">/* specificity = 1:2:1 */</span></a>
<a class="sourceLine" id="cb8-35" title="35">}</a>
<a class="sourceLine" id="cb8-36" title="36"></a>
<a class="sourceLine" id="cb8-37" title="37"><span class="pp">#id</span><span class="ex">[attribute]</span> {</a>
<a class="sourceLine" id="cb8-38" title="38">  <span class="co">/* specificity = 1:1:0 */</span></a>
<a class="sourceLine" id="cb8-39" title="39">}</a>
<a class="sourceLine" id="cb8-40" title="40"></a>
<a class="sourceLine" id="cb8-41" title="41"><span class="fu">.class</span><span class="ex">[attribute]</span> {</a>
<a class="sourceLine" id="cb8-42" title="42">  <span class="co">/* specificity = 0:2:0 */</span></a>
<a class="sourceLine" id="cb8-43" title="43">}</a>
<a class="sourceLine" id="cb8-44" title="44"></a>
<a class="sourceLine" id="cb8-45" title="45"><span class="co">/*</span></a>
<a class="sourceLine" id="cb8-46" title="46"><span class="co">  it looks strange, but this is valid CSS</span></a>
<a class="sourceLine" id="cb8-47" title="47"><span class="co">  you can repeat the same selector over and</span></a>
<a class="sourceLine" id="cb8-48" title="48"><span class="co">  over to increase its specificity.</span></a>
<a class="sourceLine" id="cb8-49" title="49"></a>
<a class="sourceLine" id="cb8-50" title="50"><span class="co">  It does not work for &lt;elements&gt;, i.e. you</span></a>
<a class="sourceLine" id="cb8-51" title="51"><span class="co">  can not do ppp to increase the specificity</span></a>
<a class="sourceLine" id="cb8-52" title="52"><span class="co">  for &lt;p&gt; tags.</span></a>
<a class="sourceLine" id="cb8-53" title="53"><span class="co">*/</span></a>
<a class="sourceLine" id="cb8-54" title="54"><span class="fu">.class.class.class.class</span> {</a>
<a class="sourceLine" id="cb8-55" title="55">  <span class="co">/* specificity = 0:4:0 */</span></a>
<a class="sourceLine" id="cb8-56" title="56">}</a></code></pre>
</div>
<p>In each case, you simply add up the total number of basic selectors, put them in the correct location and compare.</p>
<h2 id="rules-for-creating-specific-selectors">Rules for Creating Specific Selectors</h2>
<ol class="incremental" type="1">
<li>If you specify an HTML element, then it must be at the beginning of the selector. i.e.: <span class="css-class">p[attribute]</span> not <span class="css-class">[attribute]p</span>.</li>
<li>There can be a maximum of 1 HTML element in a specific selector. i.e.: <span class="css-class">p.class</span> or <span class="css-class">ul[reversed]</span>, but not <span class="css-class">pspan.class</span>.</li>
<li>There can be a maximum of 1 <span class="css-id">#ID</span> in a selector. This is because <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-selecting-specific-elements-for-styling/#fn2">an element can have at most 1 <span class="css-id">#ID</span></a>.</li>
<li>The order of <span class="css-class">.class</span>, <span class="css-attribute">[attribute]</span>, or <span class="css-id">#ID</span> doesn’t matter. i.e.: <span class="css-class">#ID.class</span> is equivalent to <span class="css-class">.class#ID</span>.</li>
<li><span class="css-class">.class</span>, <span class="css-attribute">[attribute]</span>, and <span class="css-id">#ID</span> selectors may be repeated to increase their specificity. i.e.: <span class="css-class">.class</span> has a specificity of 0:1:0, but <span class="css-class">.class.class</span> has a specificity of 0:2:0.</li>
<li>You cannot repeat HTML elements. i.e.: <span class="css-class">pppp</span> or <span class="css-class">ulul</span> have no meaning and will be ignored by the browser.</li>
<li>All selectors are written together without spaces between them. i.e.: <span class="css-class">p.class</span> is not the same as <span class="css-class">p .class</span> and <span class="css-class">#id[attribute]</span> is not the same as <span class="css-class">#id [attribute]</span>.<a href="#fn2" class="footnote-ref" id="fnref2"><sup>2</sup></a></li>
</ol>
<h2 id="final-words">Final Words</h2>
<ol class="incremental" type="1">
<li>
<p>You can be very specific about which HTML element to style on a page by stringing together various selectors associated with that element:</p>
<div class="sourceCode" id="cb9">
<pre class="sourceCode css"><code class="sourceCode css"><a class="sourceLine" id="cb9-1" title="1"><span class="co">/*</span></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="co">  select &lt;ul&gt; elements which contain the</span></a>
<a class="sourceLine" id="cb9-3" title="3"><span class="co">  reversed attribute</span></a>
<a class="sourceLine" id="cb9-4" title="4"></a>
<a class="sourceLine" id="cb9-5" title="5"><span class="co">  specificity = 0:1:1</span></a>
<a class="sourceLine" id="cb9-6" title="6"><span class="co">*/</span></a>
<a class="sourceLine" id="cb9-7" title="7">ul<span class="ex">[reversed]</span> {</a>
<a class="sourceLine" id="cb9-8" title="8"></a>
<a class="sourceLine" id="cb9-9" title="9">}</a>
<a class="sourceLine" id="cb9-10" title="10"></a>
<a class="sourceLine" id="cb9-11" title="11"><span class="co">/*</span></a>
<a class="sourceLine" id="cb9-12" title="12"><span class="co">  select &lt;ul&gt; elements which contain the</span></a>
<a class="sourceLine" id="cb9-13" title="13"><span class="co">  reversed attribute AND have a class of</span></a>
<a class="sourceLine" id="cb9-14" title="14"><span class="co">  .class1</span></a>
<a class="sourceLine" id="cb9-15" title="15"></a>
<a class="sourceLine" id="cb9-16" title="16"><span class="co">  specificity = 0:2:1</span></a>
<a class="sourceLine" id="cb9-17" title="17"><span class="co">*/</span></a>
<a class="sourceLine" id="cb9-18" title="18">ul<span class="ex">[reversed]</span><span class="fu">.class1</span> {</a>
<a class="sourceLine" id="cb9-19" title="19"></a>
<a class="sourceLine" id="cb9-20" title="20">}</a></code></pre>
</div>
</li>
<li><em>Specificity</em> is calculated by summing and arranging the total number of basic specifiers in each of the following groups:<br />
<table style="border:1px solid black;margin: auto;">
<tr>
<td style="border:1px solid black;padding:1.5em;">
IDs
</td>
<td style="border:1px solid black;padding:1.5em;">
.classes and [attributes]
</td>
<td style="border:1px solid black;padding:1.5em;">
&lt;elements&gt;
</td>
</tr>
</table>
</li>
<li>In deciding which styling rule to apply, the rule with the higher <em>specificity</em> is applied.</li>
<li>If two rules have the same <em>specificity</em> then the last rule defined is applied.</li>
<li>The universal selector always has a specificity of 0:0:0.</li>
<li>
<p>There are no spaces between the selectors &#8211; it is written as one long expression.</p>
</li>
</ol>
<h2 id="references">References</h2>
<ol class="incremental" type="1">
<li><a href="https://drafts.csswg.org/selectors-3/">CSS Selectors</a></li>
</ol>
<div class="prev">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/advanced-css-selectors-part-1/">Prev</a></p>
</div>
<div class="next">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-combinators-advanced-css-selectors-part-3/">Next</a></p>
</div>
<div class="clear">
</div>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">
<p>For now it is three values, in reality there two more values that have higher specificity and can be considered as the fourth and fifth specificity values &#8211; they will be covered in a future tutorial.<a href="#fnref1" class="footnote-back">↩</a></p>
</li>
<li id="fn2">
<p>The next tutorial will show how spaces between selectors changes the meaning of the selection expression.<a href="#fnref2" class="footnote-back">↩</a></p>
</li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-specificity-advanced-css-selectors-part-2/">CSS Specificity &#8211; Advanced CSS Selectors &#8211; Part 2</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Advanced CSS Selectors &#8211; Part 1</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/advanced-css-selectors-part-1/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Wed, 17 Apr 2019 12:42:14 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[combinator]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3813</guid>

					<description><![CDATA[<p>Expand your skill set from 5 basic CSS selectors to over 50 advanced CSS selectors.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/advanced-css-selectors-part-1/">Advanced CSS Selectors &#8211; Part 1</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
<p>We’ve seen <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-selecting-specific-elements-for-styling/">5 different ways to select page elements</a> for styling. Over the next few tutorials we will add more than 50 advanced CSS selectors for targeting HTML elements for styling.</p>
</div>
<h2 id="contents">Contents</h2>
<ol class="incremental" type="1">
<li><a href="#a-quick-recap-and-introduction">A Quick Recap and Introduction</a></li>
<li><a href="#updated-clone-page-code">Updated Clone Page Code</a></li>
<li><a href="#final-words">Final Words</a></li>
<li><a href="#references">References</a></li>
</ol>
<h2 id="a-quick-recap-and-introduction">A Quick Recap and Introduction</h2>
<p>You have seen how to style HTML elements using the following selectors:</p>
<div id="cb1" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb1-1" class="sourceLine" title="1"></a>
<a id="cb1-2" class="sourceLine" title="2"></a><span class="co">/*</span>
<a id="cb1-3" class="sourceLine" title="3"></a><span class="co">  This styling will be applied to all elements on</span>
<a id="cb1-4" class="sourceLine" title="4"></a><span class="co">  the page unless another style overrides it.</span>
<a id="cb1-5" class="sourceLine" title="5"></a><span class="co">*/</span>
<a id="cb1-6" class="sourceLine" title="6"></a><span class="op">*</span> {
<a id="cb1-7" class="sourceLine" title="7"></a>  <span class="kw">box-sizing</span>: <span class="dv">border-box</span><span class="op">;</span>
<a id="cb1-8" class="sourceLine" title="8"></a>}
<a id="cb1-9" class="sourceLine" title="9"></a>
<a id="cb1-10" class="sourceLine" title="10"></a><span class="co">/*</span>
<a id="cb1-11" class="sourceLine" title="11"></a><span class="co">  This styling will be applied to all &lt;p&gt; elements</span>
<a id="cb1-12" class="sourceLine" title="12"></a><span class="co">  on the page unless overridden by a style applied</span>
<a id="cb1-13" class="sourceLine" title="13"></a><span class="co">  via a .class, [attribute], or #ID</span>
<a id="cb1-14" class="sourceLine" title="14"></a><span class="co">*/</span>
<a id="cb1-15" class="sourceLine" title="15"></a>p {
<a id="cb1-16" class="sourceLine" title="16"></a>  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb1-17" class="sourceLine" title="17"></a>  <span class="kw">background-color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-18" class="sourceLine" title="18"></a>}
<a id="cb1-19" class="sourceLine" title="19"></a>
<a id="cb1-20" class="sourceLine" title="20"></a><span class="co">/*</span>
<a id="cb1-21" class="sourceLine" title="21"></a><span class="co">  This styling will be applied to all elements</span>
<a id="cb1-22" class="sourceLine" title="22"></a><span class="co">  with this class.</span>
<a id="cb1-23" class="sourceLine" title="23"></a>
<a id="cb1-24" class="sourceLine" title="24"></a><span class="co">  It can be overridden by other classes or [attributes]</span>
<a id="cb1-25" class="sourceLine" title="25"></a><span class="co">  that are applied to the element, but only if they are</span>
<a id="cb1-26" class="sourceLine" title="26"></a><span class="co">  defined after this one.</span>
<a id="cb1-27" class="sourceLine" title="27"></a>
<a id="cb1-28" class="sourceLine" title="28"></a><span class="co">  An #ID style will always override this style.</span>
<a id="cb1-29" class="sourceLine" title="29"></a><span class="co">*/</span>
<a id="cb1-30" class="sourceLine" title="30"></a><span class="fu">.myStyle</span> {
<a id="cb1-31" class="sourceLine" title="31"></a>  <span class="kw">color</span>: <span class="cn">blue</span><span class="op">;</span>
<a id="cb1-32" class="sourceLine" title="32"></a>  <span class="kw">background</span>: <span class="cn">yellow</span><span class="op">;</span>
<a id="cb1-33" class="sourceLine" title="33"></a>}
<a id="cb1-34" class="sourceLine" title="34"></a>
<a id="cb1-35" class="sourceLine" title="35"></a><span class="co">/*</span>
<a id="cb1-36" class="sourceLine" title="36"></a><span class="co">This styling will be applied to all elements</span>
<a id="cb1-37" class="sourceLine" title="37"></a><span class="co">matching this attribute.</span>
<a id="cb1-38" class="sourceLine" title="38"></a>
<a id="cb1-39" class="sourceLine" title="39"></a><span class="co">It can be overridden by other classes or [attributes]</span>
<a id="cb1-40" class="sourceLine" title="40"></a><span class="co">that are applied to the element, but only if they are</span>
<a id="cb1-41" class="sourceLine" title="41"></a><span class="co">defined after this one.</span>
<a id="cb1-42" class="sourceLine" title="42"></a>
<a id="cb1-43" class="sourceLine" title="43"></a><span class="co">An #ID style will always override this style.</span>
<a id="cb1-44" class="sourceLine" title="44"></a><span class="co">*/</span>
<a id="cb1-45" class="sourceLine" title="45"></a><span class="ex">[reversed]</span> {
<a id="cb1-46" class="sourceLine" title="46"></a>  <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-47" class="sourceLine" title="47"></a>  <span class="kw">background-color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb1-48" class="sourceLine" title="48"></a>}
<a id="cb1-49" class="sourceLine" title="49"></a>
<a id="cb1-50" class="sourceLine" title="50"></a><span class="co">/*</span>
<a id="cb1-51" class="sourceLine" title="51"></a><span class="co">  This styling will be applied to the element</span>
<a id="cb1-52" class="sourceLine" title="52"></a><span class="co">  with this ID. Remember: each ID must be</span>
<a id="cb1-53" class="sourceLine" title="53"></a><span class="co">  unique on the page and an element can have a</span>
<a id="cb1-54" class="sourceLine" title="54"></a><span class="co">  maximum of 1 ID.</span>
<a id="cb1-55" class="sourceLine" title="55"></a>
<a id="cb1-56" class="sourceLine" title="56"></a><span class="co">  This styling overrides any other styling</span>
<a id="cb1-57" class="sourceLine" title="57"></a><span class="co">  applied to the element.</span>
<a id="cb1-58" class="sourceLine" title="58"></a><span class="co">*/</span>
<a id="cb1-59" class="sourceLine" title="59"></a>
<a id="cb1-60" class="sourceLine" title="60"></a><span class="pp">#myID</span> {
<a id="cb1-61" class="sourceLine" title="61"></a>  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-62" class="sourceLine" title="62"></a>  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb1-63" class="sourceLine" title="63"></a>  <span class="kw">background-color</span>: <span class="cn">orange</span><span class="op">;</span>
<a id="cb1-64" class="sourceLine" title="64"></a>}</code></pre>
</div>
<p>This sort of styling is very direct: you explicitly specify the element you want styled and rely on inheritance to pass styles from parent to child elements.</p>
<p>This direct form of styling does have shortcomings &#8211; if we want to style part of the page differently, we have to explicitly create new styles for that (likely using classes) and apply them to the elements we want styled. This creates a multiplicity of style rules than can quickly become unwieldy.<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a> As well, if you apply multiple styles (via classes) then the order in which the styles were defined matters.</p>
<p>Let’s consider the <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-3/">clone page created earlier</a>: one of the things used was a <strong>card</strong> pattern for the articles on the page:</p>
<div id="cb2" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb2-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb2-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb2-3" class="sourceLine" title="3"></a>    <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">""</span><span class="kw">&gt;</span>
<a id="cb2-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb2-5" class="sourceLine" title="5"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb2-6" class="sourceLine" title="6"></a>
<a id="cb2-7" class="sourceLine" title="7"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb2-8" class="sourceLine" title="8"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb2-9" class="sourceLine" title="9"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>This worked fine, except that instead of using a generic class of <span class="css-class">.headline</span>, specific headline classes were used depending on which column the card was located: <span class="css-class">.headline-small</span>, <span class="css-class">.headline-large</span>, and <span class="css-class">.headline-medium</span>.</p>
<p>This makes moving cards from one column to another complicated because styling information (rather than content information) is embedded in the class. Moving a card requires the class be updated because its location changed.</p>
<p>CSS allows you to apply styles based on the context your content appears in. Consider:</p>
<div id="cb3" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb3-1" class="sourceLine" title="1"></a><span class="co">/*</span>
<a id="cb3-2" class="sourceLine" title="2"></a><span class="co">apply the following style to elements</span>
<a id="cb3-3" class="sourceLine" title="3"></a><span class="co">with the class .headline that are</span>
<a id="cb3-4" class="sourceLine" title="4"></a><span class="co">immediate children of elements with the</span>
<a id="cb3-5" class="sourceLine" title="5"></a><span class="co">class .card that are immediate children</span>
<a id="cb3-6" class="sourceLine" title="6"></a><span class="co">of elements with the class .left-column</span>
<a id="cb3-7" class="sourceLine" title="7"></a><span class="co">*/</span>
<a id="cb3-8" class="sourceLine" title="8"></a><span class="fu">.column-left</span> <span class="op">&gt;</span> <span class="fu">.card</span> <span class="op">&gt;</span> <span class="fu">.headline</span> {
<a id="cb3-9" class="sourceLine" title="9"></a>
<a id="cb3-10" class="sourceLine" title="10"></a>}
<a id="cb3-11" class="sourceLine" title="11"></a>
<a id="cb3-12" class="sourceLine" title="12"></a><span class="co">/*</span>
<a id="cb3-13" class="sourceLine" title="13"></a><span class="co">apply the following style to elements</span>
<a id="cb3-14" class="sourceLine" title="14"></a><span class="co">with the class .headline if their parent</span>
<a id="cb3-15" class="sourceLine" title="15"></a><span class="co">element has class .card and their</span>
<a id="cb3-16" class="sourceLine" title="16"></a><span class="co">grandparent has class .middle-column</span>
<a id="cb3-17" class="sourceLine" title="17"></a><span class="co">*/</span>
<a id="cb3-18" class="sourceLine" title="18"></a><span class="fu">.column-middle</span> <span class="op">&gt;</span> <span class="fu">.card</span> <span class="op">&gt;</span> <span class="fu">.headline</span> {
<a id="cb3-19" class="sourceLine" title="19"></a>  <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb3-20" class="sourceLine" title="20"></a>}
<a id="cb3-21" class="sourceLine" title="21"></a>
<a id="cb3-22" class="sourceLine" title="22"></a><span class="co">/*</span>
<a id="cb3-23" class="sourceLine" title="23"></a><span class="co">apply the following style to elements</span>
<a id="cb3-24" class="sourceLine" title="24"></a><span class="co">with the class .headline only if it is</span>
<a id="cb3-25" class="sourceLine" title="25"></a><span class="co">nested exactly as follows:</span>
<a id="cb3-26" class="sourceLine" title="26"></a><span class="co">  class=“right-column”</span>
<a id="cb3-27" class="sourceLine" title="27"></a><span class="co">      class=“card”</span>
<a id="cb3-28" class="sourceLine" title="28"></a><span class="co">          class=“headline”</span>
<a id="cb3-29" class="sourceLine" title="29"></a><span class="co">*/</span>
<a id="cb3-30" class="sourceLine" title="30"></a><span class="fu">.column-right</span> <span class="op">&gt;</span> <span class="fu">.card</span> <span class="op">&gt;</span> <span class="fu">.headline</span> {
<a id="cb3-31" class="sourceLine" title="31"></a>  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb3-32" class="sourceLine" title="32"></a>}</code></pre>
</div>
<p>If you replace the <span class="css-class">.headline-small</span>, <span class="css-class">.headline-large</span>, and <span class="css-class">.headline-medium</span>. style definitions in the <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-3/">clone page</a> with the above code and replace their use in the HTML with <span class="css-class">.headline</span>, you will notice everything still works correctly.</p>
<h2 id="updated-clone-page-code">Updated Clone Page Code</h2>
<p>You can see how the updated clone page <a href="https://complete-concrete-concise.com/sample/37-update-clone-page.html">looks here</a> and you can see how the original clone page <a href="https://complete-concrete-concise.com/sample/32-float.html">looks here</a>. You can also inspect the page source code using the <strong>view source</strong> tool you <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/a-quick-introduction-to-two-development-tools-built-into-your-browser/#view-page-source">learned about here</a> or inspect the updated source code below:</p>
<div id="cb4" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb4-1" class="sourceLine" title="1"></a><span class="dt">&lt;!DOCTYPE </span>HTML<span class="dt">&gt;</span>
<a id="cb4-2" class="sourceLine" title="2"></a><span class="kw">&lt;html&gt;</span>
<a id="cb4-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;head&gt;</span>
<a id="cb4-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;title&gt;</span>Clone Page<span class="kw">&lt;/title&gt;</span>
<a id="cb4-5" class="sourceLine" title="5"></a>    <span class="kw">&lt;meta</span><span class="ot"> charset=</span><span class="st">"utf-8"</span>  <span class="kw">/&gt;</span>
<a id="cb4-6" class="sourceLine" title="6"></a>
<a id="cb4-7" class="sourceLine" title="7"></a>    <span class="kw">&lt;style&gt;</span>
<a id="cb4-8" class="sourceLine" title="8"></a>
<a id="cb4-9" class="sourceLine" title="9"></a>      <span class="op">*</span> {
<a id="cb4-10" class="sourceLine" title="10"></a>        <span class="kw">box-sizing</span>: <span class="dv">border-box</span><span class="op">;</span>
<a id="cb4-11" class="sourceLine" title="11"></a>        <span class="kw">font-family</span>: <span class="dv">sans-serif</span><span class="op">;</span>
<a id="cb4-12" class="sourceLine" title="12"></a>        <span class="kw">font-size</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-13" class="sourceLine" title="13"></a>      }
<a id="cb4-14" class="sourceLine" title="14"></a>
<a id="cb4-15" class="sourceLine" title="15"></a>      img {
<a id="cb4-16" class="sourceLine" title="16"></a>        <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb4-17" class="sourceLine" title="17"></a>      }
<a id="cb4-18" class="sourceLine" title="18"></a>
<a id="cb4-19" class="sourceLine" title="19"></a>      <span class="pp">#wrapper</span> {
<a id="cb4-20" class="sourceLine" title="20"></a>        <span class="kw">width</span>: <span class="dv">960</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-21" class="sourceLine" title="21"></a>        <span class="kw">margin</span>: <span class="bu">auto</span><span class="op">;</span>
<a id="cb4-22" class="sourceLine" title="22"></a>      }
<a id="cb4-23" class="sourceLine" title="23"></a>
<a id="cb4-24" class="sourceLine" title="24"></a>      <span class="pp">#title</span> {
<a id="cb4-25" class="sourceLine" title="25"></a>        <span class="kw">background-color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb4-26" class="sourceLine" title="26"></a>        <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb4-27" class="sourceLine" title="27"></a>        <span class="kw">padding</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-28" class="sourceLine" title="28"></a>      }
<a id="cb4-29" class="sourceLine" title="29"></a>
<a id="cb4-30" class="sourceLine" title="30"></a>      <span class="pp">#site-name</span> {
<a id="cb4-31" class="sourceLine" title="31"></a>        <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-32" class="sourceLine" title="32"></a>        <span class="kw">font-weight</span>: <span class="dv">bold</span><span class="op">;</span>
<a id="cb4-33" class="sourceLine" title="33"></a>      }
<a id="cb4-34" class="sourceLine" title="34"></a>
<a id="cb4-35" class="sourceLine" title="35"></a>      <span class="pp">#login</span> {
<a id="cb4-36" class="sourceLine" title="36"></a>        <span class="kw">color</span>: <span class="cn">grey</span><span class="op">;</span>
<a id="cb4-37" class="sourceLine" title="37"></a>        <span class="kw">padding-top</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-38" class="sourceLine" title="38"></a>        <span class="kw">float</span>: <span class="dv">right</span><span class="op">;</span>
<a id="cb4-39" class="sourceLine" title="39"></a>      }
<a id="cb4-40" class="sourceLine" title="40"></a>
<a id="cb4-41" class="sourceLine" title="41"></a>      <span class="pp">#search</span> {
<a id="cb4-42" class="sourceLine" title="42"></a>        <span class="kw">color</span>: <span class="cn">grey</span><span class="op">;</span>
<a id="cb4-43" class="sourceLine" title="43"></a>        <span class="kw">float</span>: <span class="dv">right</span><span class="op">;</span>
<a id="cb4-44" class="sourceLine" title="44"></a>        <span class="kw">padding-top</span>: <span class="dv">18</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-45" class="sourceLine" title="45"></a>        <span class="kw">padding-right</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-46" class="sourceLine" title="46"></a>        <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-47" class="sourceLine" title="47"></a>      }
<a id="cb4-48" class="sourceLine" title="48"></a>
<a id="cb4-49" class="sourceLine" title="49"></a>      <span class="pp">#navbar</span> {
<a id="cb4-50" class="sourceLine" title="50"></a>        <span class="kw">background-color</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb4-51" class="sourceLine" title="51"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb4-52" class="sourceLine" title="52"></a>        <span class="kw">border-bottom</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb4-53" class="sourceLine" title="53"></a>      }
<a id="cb4-54" class="sourceLine" title="54"></a>
<a id="cb4-55" class="sourceLine" title="55"></a>      <span class="pp">#darkbox</span> {
<a id="cb4-56" class="sourceLine" title="56"></a>        <span class="kw">background-color</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb4-57" class="sourceLine" title="57"></a>        <span class="kw">height</span>: <span class="dv">100</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-58" class="sourceLine" title="58"></a>      }
<a id="cb4-59" class="sourceLine" title="59"></a>
<a id="cb4-60" class="sourceLine" title="60"></a>      <span class="pp">#content</span> {
<a id="cb4-61" class="sourceLine" title="61"></a>        <span class="kw">margin-top</span>: <span class="dv">-90</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-62" class="sourceLine" title="62"></a>      }
<a id="cb4-63" class="sourceLine" title="63"></a>
<a id="cb4-64" class="sourceLine" title="64"></a>      <span class="pp">#popular</span> {
<a id="cb4-65" class="sourceLine" title="65"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb4-66" class="sourceLine" title="66"></a>        <span class="kw">padding-left</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-67" class="sourceLine" title="67"></a>        <span class="kw">font-weight</span>: <span class="dv">bold</span><span class="op">;</span>
<a id="cb4-68" class="sourceLine" title="68"></a>      }
<a id="cb4-69" class="sourceLine" title="69"></a>
<a id="cb4-70" class="sourceLine" title="70"></a>      <span class="pp">#footer</span> {
<a id="cb4-71" class="sourceLine" title="71"></a>        <span class="kw">text-align</span>: <span class="dv">center</span><span class="op">;</span>
<a id="cb4-72" class="sourceLine" title="72"></a>        <span class="kw">padding</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-73" class="sourceLine" title="73"></a>        <span class="kw">background</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb4-74" class="sourceLine" title="74"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb4-75" class="sourceLine" title="75"></a>        <span class="kw">font-size</span>: <span class="dv">20</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-76" class="sourceLine" title="76"></a>      }
<a id="cb4-77" class="sourceLine" title="77"></a>
<a id="cb4-78" class="sourceLine" title="78"></a>      <span class="fu">.nav-item</span> {
<a id="cb4-79" class="sourceLine" title="79"></a>        <span class="kw">display</span>: <span class="dv">inline-block</span><span class="op">;</span>
<a id="cb4-80" class="sourceLine" title="80"></a>        <span class="kw">padding</span>: <span class="dv">24</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-81" class="sourceLine" title="81"></a>      }
<a id="cb4-82" class="sourceLine" title="82"></a>
<a id="cb4-83" class="sourceLine" title="83"></a>      <span class="fu">.column-left</span> {
<a id="cb4-84" class="sourceLine" title="84"></a>        <span class="kw">width</span>: <span class="dv">20</span><span class="dt">%</span><span class="op">;</span>
<a id="cb4-85" class="sourceLine" title="85"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb4-86" class="sourceLine" title="86"></a>      }
<a id="cb4-87" class="sourceLine" title="87"></a>
<a id="cb4-88" class="sourceLine" title="88"></a>      <span class="fu">.column-middle</span> {
<a id="cb4-89" class="sourceLine" title="89"></a>        <span class="kw">width</span>: <span class="dv">55</span><span class="dt">%</span><span class="op">;</span>
<a id="cb4-90" class="sourceLine" title="90"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb4-91" class="sourceLine" title="91"></a>        <span class="kw">border-left</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb4-92" class="sourceLine" title="92"></a>        <span class="kw">border-right</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb4-93" class="sourceLine" title="93"></a>      }
<a id="cb4-94" class="sourceLine" title="94"></a>
<a id="cb4-95" class="sourceLine" title="95"></a>      <span class="fu">.column-right</span> {
<a id="cb4-96" class="sourceLine" title="96"></a>        <span class="kw">width</span>: <span class="dv">25</span><span class="dt">%</span><span class="op">;</span>
<a id="cb4-97" class="sourceLine" title="97"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb4-98" class="sourceLine" title="98"></a>      }
<a id="cb4-99" class="sourceLine" title="99"></a>
<a id="cb4-100" class="sourceLine" title="100"></a>      <span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb4-101" class="sourceLine" title="101"></a>        <span class="kw">clear</span>: <span class="dv">both</span><span class="op">;</span>
<a id="cb4-102" class="sourceLine" title="102"></a>        <span class="kw">display</span>: <span class="dv">block</span><span class="op">;</span>
<a id="cb4-103" class="sourceLine" title="103"></a>        <span class="kw">content</span>: <span class="st">""</span><span class="op">;</span>
<a id="cb4-104" class="sourceLine" title="104"></a>      }
<a id="cb4-105" class="sourceLine" title="105"></a>
<a id="cb4-106" class="sourceLine" title="106"></a>      <span class="fu">.card</span> {
<a id="cb4-107" class="sourceLine" title="107"></a>        <span class="kw">padding</span>: <span class="dv">0</span> <span class="dv">16</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-108" class="sourceLine" title="108"></a>      }
<a id="cb4-109" class="sourceLine" title="109"></a>
<a id="cb4-110" class="sourceLine" title="110"></a>      <span class="fu">.image</span> {
<a id="cb4-111" class="sourceLine" title="111"></a>
<a id="cb4-112" class="sourceLine" title="112"></a>      }
<a id="cb4-113" class="sourceLine" title="113"></a>
<a id="cb4-114" class="sourceLine" title="114"></a>      <span class="co">/*</span>
<a id="cb4-115" class="sourceLine" title="115"></a><span class="co">      Use the more specific styling selectors</span>
<a id="cb4-116" class="sourceLine" title="116"></a><span class="co">      that select HTML elements based on their</span>
<a id="cb4-117" class="sourceLine" title="117"></a><span class="co">      class AND placement in the page.</span>
<a id="cb4-118" class="sourceLine" title="118"></a><span class="co">      */</span>
<a id="cb4-119" class="sourceLine" title="119"></a>      <span class="fu">.column-left</span> <span class="op">&gt;</span> <span class="fu">.card</span> <span class="op">&gt;</span> <span class="fu">.headline</span> {
<a id="cb4-120" class="sourceLine" title="120"></a>
<a id="cb4-121" class="sourceLine" title="121"></a>      }
<a id="cb4-122" class="sourceLine" title="122"></a>
<a id="cb4-123" class="sourceLine" title="123"></a>      <span class="fu">.column-middle</span> <span class="op">&gt;</span> <span class="fu">.card</span> <span class="op">&gt;</span> <span class="fu">.headline</span> {
<a id="cb4-124" class="sourceLine" title="124"></a>        <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-125" class="sourceLine" title="125"></a>      }
<a id="cb4-126" class="sourceLine" title="126"></a>
<a id="cb4-127" class="sourceLine" title="127"></a>      <span class="fu">.column-right</span> <span class="op">&gt;</span> <span class="fu">.card</span> <span class="op">&gt;</span> <span class="fu">.headline</span> {
<a id="cb4-128" class="sourceLine" title="128"></a>        <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-129" class="sourceLine" title="129"></a>      }
<a id="cb4-130" class="sourceLine" title="130"></a>
<a id="cb4-131" class="sourceLine" title="131"></a>      <span class="fu">.timestamp</span> {
<a id="cb4-132" class="sourceLine" title="132"></a>        <span class="kw">padding-top</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-133" class="sourceLine" title="133"></a>        <span class="kw">color</span>: <span class="cn">gray</span><span class="op">;</span>
<a id="cb4-134" class="sourceLine" title="134"></a>        <span class="kw">font-size</span>: <span class="dv">12</span><span class="dt">px</span><span class="op">;</span>
<a id="cb4-135" class="sourceLine" title="135"></a>      }
<a id="cb4-136" class="sourceLine" title="136"></a>
<a id="cb4-137" class="sourceLine" title="137"></a>    <span class="kw">&lt;/style&gt;</span>
<a id="cb4-138" class="sourceLine" title="138"></a>  <span class="kw">&lt;/head&gt;</span>
<a id="cb4-139" class="sourceLine" title="139"></a>  <span class="kw">&lt;body&gt;</span>
<a id="cb4-140" class="sourceLine" title="140"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"wrapper"</span><span class="kw">&gt;</span>
<a id="cb4-141" class="sourceLine" title="141"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;</span>
<a id="cb4-142" class="sourceLine" title="142"></a>        <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"site-name"</span><span class="kw">&gt;</span>clonage<span class="kw">&lt;/span&gt;</span>
<a id="cb4-143" class="sourceLine" title="143"></a>        <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"login"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>Login<span class="kw">&lt;/span&gt;</span>
<a id="cb4-144" class="sourceLine" title="144"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb4-145" class="sourceLine" title="145"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"navbar"</span><span class="kw">&gt;</span>
<a id="cb4-146" class="sourceLine" title="146"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Gear<span class="kw">&lt;/span&gt;</span>
<a id="cb4-147" class="sourceLine" title="147"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Gaming<span class="kw">&lt;/span&gt;</span>
<a id="cb4-148" class="sourceLine" title="148"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Entertainment<span class="kw">&lt;/span&gt;</span>
<a id="cb4-149" class="sourceLine" title="149"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Tomorrow<span class="kw">&lt;/span&gt;</span>
<a id="cb4-150" class="sourceLine" title="150"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Video<span class="kw">&lt;/span&gt;</span>
<a id="cb4-151" class="sourceLine" title="151"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Reviews<span class="kw">&lt;/span&gt;</span>
<a id="cb4-152" class="sourceLine" title="152"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Events<span class="kw">&lt;/span&gt;</span>
<a id="cb4-153" class="sourceLine" title="153"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Local Edition<span class="kw">&lt;/span&gt;</span>
<a id="cb4-154" class="sourceLine" title="154"></a>        <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"search"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>⌕<span class="kw">&lt;/span&gt;</span>
<a id="cb4-155" class="sourceLine" title="155"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb4-156" class="sourceLine" title="156"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"darkbox"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb4-157" class="sourceLine" title="157"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"content"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>
<a id="cb4-158" class="sourceLine" title="158"></a>        <span class="co">&lt;!--</span>
<a id="cb4-159" class="sourceLine" title="159"></a><span class="co">        Update all the .headline-small,</span>
<a id="cb4-160" class="sourceLine" title="160"></a><span class="co">        .headline-large, and .headline-medium</span>
<a id="cb4-161" class="sourceLine" title="161"></a><span class="co">        class tags to the .headline class.</span>
<a id="cb4-162" class="sourceLine" title="162"></a><span class="co">        --&gt;</span>
<a id="cb4-163" class="sourceLine" title="163"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;</span>
<a id="cb4-164" class="sourceLine" title="164"></a>          <span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">"popular"</span><span class="kw">&gt;</span>Popular Now<span class="kw">&lt;/p&gt;</span>
<a id="cb4-165" class="sourceLine" title="165"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-166" class="sourceLine" title="166"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-167" class="sourceLine" title="167"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-168" class="sourceLine" title="168"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-169" class="sourceLine" title="169"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-170" class="sourceLine" title="170"></a>              Foods that boost your learning
<a id="cb4-171" class="sourceLine" title="171"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-172" class="sourceLine" title="172"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-173" class="sourceLine" title="173"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-174" class="sourceLine" title="174"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-175" class="sourceLine" title="175"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-176" class="sourceLine" title="176"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-177" class="sourceLine" title="177"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-178" class="sourceLine" title="178"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-179" class="sourceLine" title="179"></a>              Robot arms may be the next
<a id="cb4-180" class="sourceLine" title="180"></a>              technological frontier
<a id="cb4-181" class="sourceLine" title="181"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-182" class="sourceLine" title="182"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-183" class="sourceLine" title="183"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-184" class="sourceLine" title="184"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-185" class="sourceLine" title="185"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-186" class="sourceLine" title="186"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-3.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-187" class="sourceLine" title="187"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-188" class="sourceLine" title="188"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-189" class="sourceLine" title="189"></a>              Is virtual reality going to far?
<a id="cb4-190" class="sourceLine" title="190"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-191" class="sourceLine" title="191"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-192" class="sourceLine" title="192"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-193" class="sourceLine" title="193"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-194" class="sourceLine" title="194"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-195" class="sourceLine" title="195"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-4.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-196" class="sourceLine" title="196"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-197" class="sourceLine" title="197"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-198" class="sourceLine" title="198"></a>              The latest trends in cosplay
<a id="cb4-199" class="sourceLine" title="199"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-200" class="sourceLine" title="200"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-201" class="sourceLine" title="201"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-202" class="sourceLine" title="202"></a>
<a id="cb4-203" class="sourceLine" title="203"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb4-204" class="sourceLine" title="204"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;</span>
<a id="cb4-205" class="sourceLine" title="205"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-206" class="sourceLine" title="206"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-207" class="sourceLine" title="207"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-big-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-208" class="sourceLine" title="208"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-209" class="sourceLine" title="209"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-210" class="sourceLine" title="210"></a>              Before you buy, check our review of the
<a id="cb4-211" class="sourceLine" title="211"></a>              hottest cars on the market
<a id="cb4-212" class="sourceLine" title="212"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-213" class="sourceLine" title="213"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-214" class="sourceLine" title="214"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-215" class="sourceLine" title="215"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-216" class="sourceLine" title="216"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-217" class="sourceLine" title="217"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-big-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-218" class="sourceLine" title="218"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-219" class="sourceLine" title="219"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-220" class="sourceLine" title="220"></a>              Health benefits of fresh fruits
<a id="cb4-221" class="sourceLine" title="221"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-222" class="sourceLine" title="222"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-223" class="sourceLine" title="223"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-224" class="sourceLine" title="224"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb4-225" class="sourceLine" title="225"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;</span>
<a id="cb4-226" class="sourceLine" title="226"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-227" class="sourceLine" title="227"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-228" class="sourceLine" title="228"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-medium-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-229" class="sourceLine" title="229"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-230" class="sourceLine" title="230"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-231" class="sourceLine" title="231"></a>              The best places to visit on Jupiter
<a id="cb4-232" class="sourceLine" title="232"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-233" class="sourceLine" title="233"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-234" class="sourceLine" title="234"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-235" class="sourceLine" title="235"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-236" class="sourceLine" title="236"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-237" class="sourceLine" title="237"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-medium-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-238" class="sourceLine" title="238"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-239" class="sourceLine" title="239"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-240" class="sourceLine" title="240"></a>              The latest smart watches monitor your
<a id="cb4-241" class="sourceLine" title="241"></a>              body's vitals while looking stylish
<a id="cb4-242" class="sourceLine" title="242"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-243" class="sourceLine" title="243"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-244" class="sourceLine" title="244"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-245" class="sourceLine" title="245"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb4-246" class="sourceLine" title="246"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb4-247" class="sourceLine" title="247"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-medium-3.jpg"</span><span class="kw">&gt;</span>
<a id="cb4-248" class="sourceLine" title="248"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-249" class="sourceLine" title="249"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb4-250" class="sourceLine" title="250"></a>              Keeping yourself safe while shopping online
<a id="cb4-251" class="sourceLine" title="251"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb4-252" class="sourceLine" title="252"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb4-253" class="sourceLine" title="253"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb4-254" class="sourceLine" title="254"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb4-255" class="sourceLine" title="255"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb4-256" class="sourceLine" title="256"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"footer"</span><span class="kw">&gt;</span>Copyright 2018<span class="kw">&lt;/div&gt;</span>
<a id="cb4-257" class="sourceLine" title="257"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb4-258" class="sourceLine" title="258"></a>
<a id="cb4-259" class="sourceLine" title="259"></a>  <span class="kw">&lt;/body&gt;</span>
<a id="cb4-260" class="sourceLine" title="260"></a><span class="kw">&lt;/html&gt;</span></code></pre>
</div>
<h2 id="final-words">Final Words</h2>
<p>You’ve received a brief introduction to one advanced CSS selector known as a <strong>combinator</strong>. This <em>combinator</em> (denoted with the symbol ‘<strong>&gt;</strong>’) specifies an explicit <strong>parent-child</strong> relationship for the selection.</p>
<p>The next few tutorials will cover in more detail the various <strong>combinators</strong>, <strong>pseudo-classes</strong>, and <strong>pseudo-elements</strong> that can be used for advanced CSS selection of HTML elements (there are more than 50 of them).</p>
<h2 id="references">References</h2>
<ol class="incremental" type="1">
<li><a href="https://drafts.csswg.org/selectors-3/">CSS Selectors</a></li>
</ol>
<div class="prev">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-inheritance-and-default-values//">Prev</a></p>
</div>
<div class="next">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-specificity-advanced-css-selectors-part-2/">Next</a></p>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">Ok, styling rules can become very messy, very quickly if you are not clear in what you are doing. Always ensure you constructing your rules in a well ordered rather than <em>ad-hoc</em> manner.<a class="footnote-back" href="#fnref1">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/advanced-css-selectors-part-1/">Advanced CSS Selectors &#8211; Part 1</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; Understanding Inheritance and Default Values</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-inheritance-and-default-values/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Fri, 22 Mar 2019 19:59:11 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css default values]]></category>
		<category><![CDATA[css inheritance]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3801</guid>

					<description><![CDATA[<p>Learn which CSS properties child elements inherit from their parents and what their default values are.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-inheritance-and-default-values/">CSS &#8211; Understanding Inheritance and Default Values</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
<p>You’ve implicitly encountered inheritance and default values while working with CSS.</p>
</div>
<h2 id="contents">Contents</h2>
<ol class="incremental" type="1">
<li><a href="#inheritance">Inheritance</a></li>
<li><a href="#default-values">Default Values</a></li>
<li><a href="#table-of-inheritance-and-default-values">Table of Inheritance and Default Values</a></li>
<li><a href="#the-inherit-value">The ‘inherit’ Value</a></li>
<li><a href="#the-default-value">The ‘default’ Value</a></li>
<li><a href="#final-words">Final Words</a></li>
<li><a href="#references">References</a></li>
</ol>
<h2 id="inheritance">Inheritance</h2>
<p>When working with CSS, you probably noticed that styling like this:</p>
<div id="cb1" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb1-1" class="sourceLine" title="1"></a><span class="fu">.important</span> {
<a id="cb1-2" class="sourceLine" title="2"></a>  <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>When applied to HTML like this:</p>
<div id="cb2" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb2-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"important"</span><span class="kw">&gt;</span>
<a id="cb2-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;p&gt;</span>This is important!<span class="kw">&lt;/p&gt;</span>
<a id="cb2-3" class="sourceLine" title="3"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Results in output that looks like this:</p>
<div class="html-output">
<style>
  .x1-css-inheritance-important {
    font-size:32px;
  }
</style>
<div class="x1-css-inheritance-important">
<p>This is important!</p>
</div>
</div>
<p>This is because the <span class="html-tag">p</span> element <strong>inherits</strong> the <span class="css-property">font-size</span> property applied to its parent <span class="html-tag">div</span>.</p>
<p>Not all properties are inherited by child elements.</p>
<p>Consider the following CSS:</p>
<div id="cb3" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb3-1" class="sourceLine" title="1"></a><span class="fu">.important</span> {
<a id="cb3-2" class="sourceLine" title="2"></a>  <span class="kw">border</span>: <span class="dv">1</span><span class="dt">px</span> <span class="cn">red</span> <span class="dv">solid</span><span class="op">;</span>
<a id="cb3-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>When applied to the following HTML:</p>
<div id="cb4" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb4-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"important"</span><span class="kw">&gt;</span>
<a id="cb4-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;p&gt;</span>This is important!<span class="kw">&lt;/p&gt;</span>
<a id="cb4-3" class="sourceLine" title="3"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Results in the <span class="css-property">border</span> only applied to the <span class="html-tag">div</span> element and not the <span class="html-tag">p</span> element:</p>
<div class="html-output">
<style>
  .x2-css-inheritance-important {
    border:1px solid red;
  }
</style>
<div class="x2-css-inheritance-important">
<p>This is important!</p>
</div>
</div>
<p>If the <span class="html-tag">p</span> tag inherited the border property from the parent <span class="html-tag">div</span> tag, it would have looked like this:</p>
<div class="html-output">
<style>
  .x2-css-inheritance-important {
    border:1px solid red;
  }
</style>
<div class="x2-css-inheritance-important">
<p class="x2-css-inheritance-important">This is important!</p>
</div>
</div>
<p>Which is, probably, not what you want.</p>
<h2 id="default-values">Default Values</h2>
<p>When you write some HTML like:</p>
<div id="cb5" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb5-1" class="sourceLine" title="1"></a><span class="dt">&lt;!DOCTYPE </span>HTML<span class="dt">&gt;</span>
<a id="cb5-2" class="sourceLine" title="2"></a><span class="kw">&lt;html&gt;</span>
<a id="cb5-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;head&gt;</span>
<a id="cb5-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;title&gt;</span>Hello World<span class="kw">&lt;/title&gt;</span>
<a id="cb5-5" class="sourceLine" title="5"></a>    <span class="kw">&lt;meta</span><span class="ot"> charset=</span><span class="st">"utf-8"</span>  <span class="kw">/&gt;</span>
<a id="cb5-6" class="sourceLine" title="6"></a>  <span class="kw">&lt;/head&gt;</span>
<a id="cb5-7" class="sourceLine" title="7"></a>  <span class="kw">&lt;body&gt;</span>
<a id="cb5-8" class="sourceLine" title="8"></a>    <span class="kw">&lt;p&gt;</span>Hello World!<span class="kw">&lt;/p&gt;</span>
<a id="cb5-9" class="sourceLine" title="9"></a>  <span class="kw">&lt;/body&gt;</span>
<a id="cb5-10" class="sourceLine" title="10"></a><span class="kw">&lt;/html&gt;</span></code></pre>
</div>
<p>You see <strong>Hello World!</strong> displayed in the browser.</p>
<p>It is very likely that the font will be <strong>serif</strong> or <strong>sans serif</strong>, it will be 16px in size, the text will be <span class="css-value">black</span> on a <span class="css-value">white</span> background, and there is no border &#8211; and you didn’t have to style anything.</p>
<p>This is because every CSS property has a default value. The default value may be changed through inheritance or when you explicitly set the value.</p>
<h2 id="table-of-inheritance-and-default-values">Table of Inheritance and Default Values</h2>
<p>The following table shows which CSS properties (that we’ve seen) are inherited by child elements from their parents.</p>
<p>It also shows the default values for those CSS properties.</p>
<div class="p-note">
<p>Browser implementations sometimes set values other than what is defined in the CSS specification. Footnotes are given for many of the values and any alternate values given should be regarded as informative rather than absolute.</p>
</div>
<table style="margin-right: auto;">
<thead>
<tr class="header">
<th style="text-align: left;">CSS Property</th>
<th>Inherited</th>
<th>Default Value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">color</span></td>
<td><span class="green-text">Yes</span></td>
<td>Depends on the browser (usually <span class="css-value">black</span>)<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property" style="white-space: nowrap;">background-color</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">transparent</span><a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">padding</span></td>
<td><span class="red-text">No</span></td>
<td>See the individual properties</td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">padding-left</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">padding-right</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">padding-top</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">padding-bottom</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref6" class="footnote-ref" href="#fn6"><sup>6</sup></a></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">margin</span></td>
<td><span class="red-text">No</span></td>
<td>See the individual properties</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">margin-left</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref7" class="footnote-ref" href="#fn7"><sup>7</sup></a></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">margin-right</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref8" class="footnote-ref" href="#fn8"><sup>8</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">margin-top</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref9" class="footnote-ref" href="#fn9"><sup>9</sup></a></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">margin-bottom</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">0</span><a id="fnref10" class="footnote-ref" href="#fn10"><sup>10</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">border</span></td>
<td><span class="red-text">No</span></td>
<td>The border is <span class="css-value">transparent</span> and has a style of <span class="css-value">none</span></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">display</span></td>
<td><span class="red-text">No</span></td>
<td>Depends on the HTML element, but the most common are <span class="css-value">inline</span> and <span class="css-value">block</span><a id="fnref11" class="footnote-ref" href="#fn11"><sup>11</sup></a>.</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">width</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">auto</span></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">height</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">auto</span></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">box-sizing</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">content-box</span></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">font-size</span></td>
<td><span class="green-text">Yes</span></td>
<td><span class="css-value">medium</span> (<em>usually</em> 16px)<a id="fnref12" class="footnote-ref" href="#fn12"><sup>12</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">font-family</span></td>
<td><span class="green-text">Yes</span></td>
<td>Depends on the browser</td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">font-weight</span></td>
<td><span class="green-text">Yes</span></td>
<td><span class="css-value">normal</span><a id="fnref13" class="footnote-ref" href="#fn13"><sup>13</sup></a></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">font-style</span></td>
<td><span class="green-text">Yes</span></td>
<td><span class="css-value">normal</span><a id="fnref14" class="footnote-ref" href="#fn14"><sup>14</sup></a></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">line-height</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">normal</span></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">text-align</span></td>
<td><span class="red-text">No</span></td>
<td>A <strong>nameless value</strong> that acts as ‘left’ if the text direction is left-to-right and ‘right’ if ‘direction’ is right-to-left.</td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">float</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">none</span></td>
</tr>
<tr class="odd">
<td style="text-align: left;"><span class="css-property">clear</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">none</span></td>
</tr>
<tr class="even">
<td style="text-align: left;"><span class="css-property">content</span></td>
<td><span class="red-text">No</span></td>
<td><span class="css-value">normal</span></td>
</tr>
</tbody>
</table>
<h2 id="the-inherit-value">The ‘inherit’ Value</h2>
<p>You can force a child element to inherit its parent’s property by using the CSS value <span class="css-value">inherit</span>:</p>
<div id="cb6" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb6-1" class="sourceLine" title="1"></a><span class="fu">.important</span> {
<a id="cb6-2" class="sourceLine" title="2"></a>  <span class="kw">border</span>: <span class="dv">1</span><span class="dt">px</span> <span class="cn">red</span> <span class="dv">solid</span><span class="op">;</span>
<a id="cb6-3" class="sourceLine" title="3"></a>}
<a id="cb6-4" class="sourceLine" title="4"></a>
<a id="cb6-5" class="sourceLine" title="5"></a><span class="fu">.what-will-this-do</span> {
<a id="cb6-6" class="sourceLine" title="6"></a>  <span class="kw">border</span>: <span class="bu">inherit</span><span class="op">;</span>
<a id="cb6-7" class="sourceLine" title="7"></a>}</code></pre>
</div>
<p>When applied to the following HTML:</p>
<div id="cb7" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb7-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"important"</span><span class="kw">&gt;</span>
<a id="cb7-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;p</span><span class="ot"> class=</span><span class="st">"what-will-this-do"</span><span class="kw">&gt;</span>This is important!<span class="kw">&lt;/p&gt;</span>
<a id="cb7-3" class="sourceLine" title="3"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Will cause the child element to inherit the parent’s <span class="css-property">border</span> property:</p>
<div class="html-output">
<style>
  .x3-css-inheritance-important {
    border:1px solid red;
  }
  .x3-what-will-this-do {
    border: inherit;
  }
</style>
<div class="x3-css-inheritance-important">
<p class="x3-what-will-this-do">This is important!</p>
</div>
</div>
<h2 id="the-default-value">The ‘default’ Value</h2>
<p>If you want to reset an element’s property to its default value, you can use the CSS value <span class="css-value">initial</span><a id="fnref15" class="footnote-ref" href="#fn15"><sup>15</sup></a>.</p>
<p>Consider the following styling:</p>
<div id="cb8" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb8-1" class="sourceLine" title="1"></a>p {
<a id="cb8-2" class="sourceLine" title="2"></a>  <span class="kw">color</span>: <span class="cn">red</span><span class="op">;</span>  
<a id="cb8-3" class="sourceLine" title="3"></a>}
<a id="cb8-4" class="sourceLine" title="4"></a><span class="fu">.default</span> {
<a id="cb8-5" class="sourceLine" title="5"></a>  <span class="kw">color</span>: initial<span class="op">;</span>
<a id="cb8-6" class="sourceLine" title="6"></a>}</code></pre>
</div>
<p>When applied to the following code:</p>
<div id="cb9" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb9-1" class="sourceLine" title="1"></a><span class="kw">&lt;p</span> <span class="kw">&gt;</span>This is some styled text!<span class="kw">&lt;/p&gt;</span>
<a id="cb9-2" class="sourceLine" title="2"></a><span class="kw">&lt;p</span><span class="ot"> class=</span><span class="st">"default"</span><span class="kw">&gt;</span>This is some default styled text<span class="kw">&lt;/p&gt;</span></code></pre>
</div>
<p>Results in the following:<a id="fnref16" class="footnote-ref" href="#fn16"><sup>16</sup></a></p>
<div class="html-output x4">
<style>
  .x4 p {
    color: red;
  }
  .x4 .x4-default {
    color: initial;
  }
</style>
<div>
<p>This is some styled text!</p>
<p class="x4-default">This is some default styled text</p>
</div>
</div>
<h2 id="final-words">Final Words</h2>
<p>Child elements may inherit CSS values from their parents &#8211; it depends on the specific CSS property.</p>
<p>All HTML elements have default styles applied to them. Some of these styles are determined by browser settings, others from the CSS specification.</p>
<h2 id="references">References</h2>
<ol class="incremental" type="1">
<li><a href="https://www.w3.org/TR/html5/rendering.html">CSS Default Properties</a></li>
<li><a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/propidx.html#q24.0">CSS Inheritance</a></li>
<li><a href="https://dxr.mozilla.org/mozilla-central/source/layout/style/res/html.css">Firefox’s Default Style Settings</a></li>
<li><a href="https://gist.github.com/ambidexterich/34828a904dd97dd2a345">Chrome’s Default Style Settings</a></li>
</ol>
<div class="prev">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/comments-in-html-and-css/">Prev</a></p>
</div>
<div class="next">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/advanced-css-selectors-part-1/">Next</a></p>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">The &lt;mark&gt; tag has a default <span class="css-property">color</span> of <span class="css-value">black</span>. The &lt;a&gt; tag default color is defined by the browser &#8211; it is usually <span class="css-value">#0000EE</span> for an unvisited link, <span class="css-value">#551A8B</span> for a visited link, and <span class="css-value">#EE0000</span> for a link you are hovering over.<a class="footnote-back" href="#fnref1">↩</a></li>
<li id="fn2">The &lt;mark&gt; tag has a default <span class="css-property">background-color</span> of <span class="css-value">yellow</span>.<a class="footnote-back" href="#fnref2">↩</a></li>
<li id="fn3">This is true for all the HTML elements we have seen so far. Some HTML elements we haven’t seen may have a non-zero default value.<a class="footnote-back" href="#fnref3">↩</a></li>
<li id="fn4">This is true for all the HTML elements we have seen so far. Some HTML elements we haven’t seen may have a non-zero default value.<a class="footnote-back" href="#fnref4">↩</a></li>
<li id="fn5">This is true for all the HTML elements we have seen so far. Some HTML elements we haven’t seen may have a non-zero default value.<a class="footnote-back" href="#fnref5">↩</a></li>
<li id="fn6">This is true for all the HTML elements we have seen so far. Some HTML elements we haven’t seen may have a non-zero default value.<a class="footnote-back" href="#fnref6">↩</a></li>
<li id="fn7">This is true for all the HTML elements we have seen so far. Some HTML elements we haven’t seen may have a non-zero default value.<a class="footnote-back" href="#fnref7">↩</a></li>
<li id="fn8">This is true for all the HTML elements we have seen so far. Some HTML elements we haven’t seen may have a non-zero default value.<a class="footnote-back" href="#fnref8">↩</a></li>
<li id="fn9">This is true for most HTML elements we have seen so far. For &lt;p&gt; tags it is equal to the font-size. The &lt;h1&gt; &lt;through &lt;h6&gt; also have default values for top and bottom margin that are non-zero &#8211; the specific value depends on the tag.<a class="footnote-back" href="#fnref9">↩</a></li>
<li id="fn10">This is true for most HTML elements we have seen so far. For &lt;p&gt; tags it is equal to the font-size. The &lt;h1&gt; &lt;through &lt;h6&gt; also have default values for top and bottom margin that are non-zero &#8211; the specific value depends on the tag.<a class="footnote-back" href="#fnref10">↩</a></li>
<li id="fn11">The following tags have a default <span class="css-property">display</span> of <span class="css-value">none</span>: &lt;head&gt;, &lt;title&gt;, and &lt;meta&gt;. The following tags have a a default <span class="css-property">display</span> of <span class="css-value">block</span>: &lt;html&gt;, &lt;body&gt;, &lt;h1&gt; through &lt;h6&gt;, &lt;img&gt;, &lt;ol&gt;, &lt;ul&gt;, &lt;li&gt;, and &lt;p&gt;. The following tags have a a default <span class="css-property">display</span> of <span class="css-value">inline</span>: &lt;strong&gt;, &lt;em&gt;, &lt;i&gt;, &lt;mark&gt;, and &lt;a&gt;.<a class="footnote-back" href="#fnref11">↩</a></li>
<li id="fn12">The &lt;h1&gt; through &lt;h6&gt; tags have varying default font sizes. Assuming 16px as the default font size: H1 = 32px, H2 = 24px, H3 = 19px, H4 = 16px, H5 = 13px, and H6 = 11px.<a class="footnote-back" href="#fnref12">↩</a></li>
<li id="fn13">The &lt;h1&gt; through &lt;h6&gt; and the &lt;b&gt; and &lt;strong&gt; tags have a default <span class="css-property">font-weight</span> of <span class="css-value">bold</span>.<a class="footnote-back" href="#fnref13">↩</a></li>
<li id="fn14">The &lt;i&gt; and &lt;em&gt; tags have a default <span class="css-property">font-style</span> of <span class="css-value">italic</span>.<a class="footnote-back" href="#fnref14">↩</a></li>
<li id="fn15">Yes, it would make more sense if it was called <span class="css-value">default</span>, but the CSS specification calls it <span class="css-value">initial</span>.<a class="footnote-back" href="#fnref15">↩</a></li>
<li id="fn16">If your default <span class="css-property">color</span> (set in the browser) is <span class="css-value">red</span>, then both outputs will be red.<a class="footnote-back" href="#fnref16">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-inheritance-and-default-values/">CSS &#8211; Understanding Inheritance and Default Values</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; A More Advanced Float Example: Part 3</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-3/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Tue, 08 Jan 2019 18:51:51 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3765</guid>

					<description><![CDATA[<p>A detailed walk through the completed code.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-3/">CSS &#8211; A More Advanced Float Example: Part 3</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
<p>A detailed walk through the code.</p>
</div>
<h2>Contents</h2>
<ol class="incremental" type="1">
<li><a href="#the-final-page">The Final Page</a></li>
<li><a href="#source-code">Source Code</a></li>
<li><a href="#detailed-code-walkthrough">Detailed Code Walkthrough</a>
<ol class="incremental" type="1">
<li><a href="#setting-some-page-level-defaults">Setting Some Page Level Defaults</a></li>
<li><a href="#the-highest-level-structure">The Highest Level Structure</a></li>
<li><a href="#the-wrapper">The Wrapper</a></li>
<li><a href="#the-title">The Title</a></li>
<li><a href="#the-navigation-bar">The Navigation Bar</a></li>
<li><a href="#the-dark-box">The Dark Box</a></li>
<li><a href="#the-content">The Content</a></li>
<li><a href="#the-column-left">The column-left</a></li>
<li><a href="#the-column-middle">The column-middle</a></li>
<li><a href="#the-column-right">The column-right</a></li>
<li><a href="#the-card">The card</a></li>
<li><a href="#the-footer">The footer</a></li>
</ol>
</li>
<li><a href="#final-thoughts">Final Thoughts</a></li>
<li><a href="#image-credits">Image Credits</a></li>
</ol>
<h2 id="the-final-page">The Final Page</h2>
<p>You can see the finished page <a href="https://complete-concrete-concise.com/sample/32-float.html">here</a>.</p>
<p>It is best viewed in a browser window that is 960px wide or larger.</p>
<h2 id="source-code">Source Code</h2>
<div id="cb1" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb1-1" class="sourceLine" title="1"></a><span class="dt">&lt;!DOCTYPE </span>HTML<span class="dt">&gt;</span>
<a id="cb1-2" class="sourceLine" title="2"></a><span class="kw">&lt;html&gt;</span>
<a id="cb1-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;head&gt;</span>
<a id="cb1-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;title&gt;</span>Clone Page<span class="kw">&lt;/title&gt;</span>
<a id="cb1-5" class="sourceLine" title="5"></a>    <span class="kw">&lt;meta</span><span class="ot"> charset=</span><span class="st">"utf-8"</span>  <span class="kw">/&gt;</span>
<a id="cb1-6" class="sourceLine" title="6"></a>
<a id="cb1-7" class="sourceLine" title="7"></a>    <span class="kw">&lt;style&gt;</span>
<a id="cb1-8" class="sourceLine" title="8"></a>
<a id="cb1-9" class="sourceLine" title="9"></a>      <span class="op">*</span> {
<a id="cb1-10" class="sourceLine" title="10"></a>        <span class="kw">box-sizing</span>: <span class="dv">border-box</span><span class="op">;</span>
<a id="cb1-11" class="sourceLine" title="11"></a>        <span class="kw">font-family</span>: <span class="dv">sans-serif</span><span class="op">;</span>
<a id="cb1-12" class="sourceLine" title="12"></a>        <span class="kw">font-size</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-13" class="sourceLine" title="13"></a>      }
<a id="cb1-14" class="sourceLine" title="14"></a>
<a id="cb1-15" class="sourceLine" title="15"></a>      img {
<a id="cb1-16" class="sourceLine" title="16"></a>        <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-17" class="sourceLine" title="17"></a>      }
<a id="cb1-18" class="sourceLine" title="18"></a>
<a id="cb1-19" class="sourceLine" title="19"></a>      <span class="pp">#wrapper</span> {
<a id="cb1-20" class="sourceLine" title="20"></a>        <span class="kw">width</span>: <span class="dv">960</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-21" class="sourceLine" title="21"></a>        <span class="kw">margin</span>: <span class="bu">auto</span><span class="op">;</span>
<a id="cb1-22" class="sourceLine" title="22"></a>      }
<a id="cb1-23" class="sourceLine" title="23"></a>
<a id="cb1-24" class="sourceLine" title="24"></a>      <span class="pp">#title</span> {
<a id="cb1-25" class="sourceLine" title="25"></a>        <span class="kw">background-color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-26" class="sourceLine" title="26"></a>        <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb1-27" class="sourceLine" title="27"></a>        <span class="kw">padding</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-28" class="sourceLine" title="28"></a>      }
<a id="cb1-29" class="sourceLine" title="29"></a>
<a id="cb1-30" class="sourceLine" title="30"></a>      <span class="pp">#site-name</span> {
<a id="cb1-31" class="sourceLine" title="31"></a>        <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-32" class="sourceLine" title="32"></a>        <span class="kw">font-weight</span>: <span class="dv">bold</span><span class="op">;</span>
<a id="cb1-33" class="sourceLine" title="33"></a>      }
<a id="cb1-34" class="sourceLine" title="34"></a>
<a id="cb1-35" class="sourceLine" title="35"></a>      <span class="pp">#login</span> {
<a id="cb1-36" class="sourceLine" title="36"></a>        <span class="kw">color</span>: <span class="cn">grey</span><span class="op">;</span>
<a id="cb1-37" class="sourceLine" title="37"></a>        <span class="kw">padding-top</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-38" class="sourceLine" title="38"></a>        <span class="kw">float</span>: <span class="dv">right</span><span class="op">;</span>
<a id="cb1-39" class="sourceLine" title="39"></a>      }
<a id="cb1-40" class="sourceLine" title="40"></a>
<a id="cb1-41" class="sourceLine" title="41"></a>      <span class="pp">#search</span> {
<a id="cb1-42" class="sourceLine" title="42"></a>        <span class="kw">color</span>: <span class="cn">grey</span><span class="op">;</span>
<a id="cb1-43" class="sourceLine" title="43"></a>        <span class="kw">float</span>: <span class="dv">right</span><span class="op">;</span>
<a id="cb1-44" class="sourceLine" title="44"></a>        <span class="kw">padding-top</span>: <span class="dv">18</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-45" class="sourceLine" title="45"></a>        <span class="kw">padding-right</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-46" class="sourceLine" title="46"></a>        <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-47" class="sourceLine" title="47"></a>      }
<a id="cb1-48" class="sourceLine" title="48"></a>
<a id="cb1-49" class="sourceLine" title="49"></a>      <span class="pp">#navbar</span> {
<a id="cb1-50" class="sourceLine" title="50"></a>        <span class="kw">background-color</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb1-51" class="sourceLine" title="51"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-52" class="sourceLine" title="52"></a>        <span class="kw">border-bottom</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb1-53" class="sourceLine" title="53"></a>      }
<a id="cb1-54" class="sourceLine" title="54"></a>
<a id="cb1-55" class="sourceLine" title="55"></a>      <span class="pp">#darkbox</span> {
<a id="cb1-56" class="sourceLine" title="56"></a>        <span class="kw">background-color</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb1-57" class="sourceLine" title="57"></a>        <span class="kw">height</span>: <span class="dv">100</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-58" class="sourceLine" title="58"></a>      }
<a id="cb1-59" class="sourceLine" title="59"></a>
<a id="cb1-60" class="sourceLine" title="60"></a>      <span class="pp">#content</span> {
<a id="cb1-61" class="sourceLine" title="61"></a>        <span class="kw">margin-top</span>: <span class="dv">-90</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-62" class="sourceLine" title="62"></a>      }
<a id="cb1-63" class="sourceLine" title="63"></a>
<a id="cb1-64" class="sourceLine" title="64"></a>      <span class="pp">#popular</span> {
<a id="cb1-65" class="sourceLine" title="65"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-66" class="sourceLine" title="66"></a>        <span class="kw">padding-left</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-67" class="sourceLine" title="67"></a>        <span class="kw">font-weight</span>: <span class="dv">bold</span><span class="op">;</span>
<a id="cb1-68" class="sourceLine" title="68"></a>      }
<a id="cb1-69" class="sourceLine" title="69"></a>
<a id="cb1-70" class="sourceLine" title="70"></a>      <span class="pp">#footer</span> {
<a id="cb1-71" class="sourceLine" title="71"></a>        <span class="kw">text-align</span>: <span class="dv">center</span><span class="op">;</span>
<a id="cb1-72" class="sourceLine" title="72"></a>        <span class="kw">padding</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-73" class="sourceLine" title="73"></a>        <span class="kw">background</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb1-74" class="sourceLine" title="74"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-75" class="sourceLine" title="75"></a>        <span class="kw">font-size</span>: <span class="dv">20</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-76" class="sourceLine" title="76"></a>      }
<a id="cb1-77" class="sourceLine" title="77"></a>
<a id="cb1-78" class="sourceLine" title="78"></a>      <span class="fu">.nav-item</span> {
<a id="cb1-79" class="sourceLine" title="79"></a>        <span class="kw">display</span>: <span class="dv">inline-block</span><span class="op">;</span>
<a id="cb1-80" class="sourceLine" title="80"></a>        <span class="kw">padding</span>: <span class="dv">24</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-81" class="sourceLine" title="81"></a>      }
<a id="cb1-82" class="sourceLine" title="82"></a>
<a id="cb1-83" class="sourceLine" title="83"></a>      <span class="fu">.column-left</span> {
<a id="cb1-84" class="sourceLine" title="84"></a>        <span class="kw">width</span>: <span class="dv">20</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-85" class="sourceLine" title="85"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb1-86" class="sourceLine" title="86"></a>      }
<a id="cb1-87" class="sourceLine" title="87"></a>
<a id="cb1-88" class="sourceLine" title="88"></a>      <span class="fu">.column-middle</span> {
<a id="cb1-89" class="sourceLine" title="89"></a>        <span class="kw">width</span>: <span class="dv">55</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-90" class="sourceLine" title="90"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb1-91" class="sourceLine" title="91"></a>        <span class="kw">border-left</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb1-92" class="sourceLine" title="92"></a>        <span class="kw">border-right</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb1-93" class="sourceLine" title="93"></a>      }
<a id="cb1-94" class="sourceLine" title="94"></a>
<a id="cb1-95" class="sourceLine" title="95"></a>      <span class="fu">.column-right</span> {
<a id="cb1-96" class="sourceLine" title="96"></a>        <span class="kw">width</span>: <span class="dv">25</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-97" class="sourceLine" title="97"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb1-98" class="sourceLine" title="98"></a>      }
<a id="cb1-99" class="sourceLine" title="99"></a>
<a id="cb1-100" class="sourceLine" title="100"></a>      <span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb1-101" class="sourceLine" title="101"></a>        <span class="kw">clear</span>: <span class="dv">both</span><span class="op">;</span>
<a id="cb1-102" class="sourceLine" title="102"></a>        <span class="kw">display</span>: <span class="dv">block</span><span class="op">;</span>
<a id="cb1-103" class="sourceLine" title="103"></a>        <span class="kw">content</span>: <span class="st">""</span><span class="op">;</span>
<a id="cb1-104" class="sourceLine" title="104"></a>      }
<a id="cb1-105" class="sourceLine" title="105"></a>
<a id="cb1-106" class="sourceLine" title="106"></a>      <span class="fu">.card</span> {
<a id="cb1-107" class="sourceLine" title="107"></a>        <span class="kw">padding</span>: <span class="dv">0</span> <span class="dv">16</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-108" class="sourceLine" title="108"></a>      }
<a id="cb1-109" class="sourceLine" title="109"></a>
<a id="cb1-110" class="sourceLine" title="110"></a>      <span class="fu">.image</span> {
<a id="cb1-111" class="sourceLine" title="111"></a>
<a id="cb1-112" class="sourceLine" title="112"></a>      }
<a id="cb1-113" class="sourceLine" title="113"></a>
<a id="cb1-114" class="sourceLine" title="114"></a>      <span class="fu">.headline-small</span> {
<a id="cb1-115" class="sourceLine" title="115"></a>
<a id="cb1-116" class="sourceLine" title="116"></a>      }
<a id="cb1-117" class="sourceLine" title="117"></a>
<a id="cb1-118" class="sourceLine" title="118"></a>      <span class="fu">.headline-medium</span> {
<a id="cb1-119" class="sourceLine" title="119"></a>        <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-120" class="sourceLine" title="120"></a>      }
<a id="cb1-121" class="sourceLine" title="121"></a>
<a id="cb1-122" class="sourceLine" title="122"></a>      <span class="fu">.headline-large</span> {
<a id="cb1-123" class="sourceLine" title="123"></a>        <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-124" class="sourceLine" title="124"></a>      }
<a id="cb1-125" class="sourceLine" title="125"></a>
<a id="cb1-126" class="sourceLine" title="126"></a>      <span class="fu">.timestamp</span> {
<a id="cb1-127" class="sourceLine" title="127"></a>        <span class="kw">padding-top</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-128" class="sourceLine" title="128"></a>        <span class="kw">color</span>: <span class="cn">gray</span><span class="op">;</span>
<a id="cb1-129" class="sourceLine" title="129"></a>        <span class="kw">font-size</span>: <span class="dv">12</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-130" class="sourceLine" title="130"></a>      }
<a id="cb1-131" class="sourceLine" title="131"></a>
<a id="cb1-132" class="sourceLine" title="132"></a>    <span class="kw">&lt;/style&gt;</span>
<a id="cb1-133" class="sourceLine" title="133"></a>  <span class="kw">&lt;/head&gt;</span>
<a id="cb1-134" class="sourceLine" title="134"></a>  <span class="kw">&lt;body&gt;</span>
<a id="cb1-135" class="sourceLine" title="135"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"wrapper"</span><span class="kw">&gt;</span>
<a id="cb1-136" class="sourceLine" title="136"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;</span>
<a id="cb1-137" class="sourceLine" title="137"></a>        <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"site-name"</span><span class="kw">&gt;</span>clonage<span class="kw">&lt;/span&gt;</span>
<a id="cb1-138" class="sourceLine" title="138"></a>        <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"login"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>Login<span class="kw">&lt;/span&gt;</span>
<a id="cb1-139" class="sourceLine" title="139"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-140" class="sourceLine" title="140"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"navbar"</span><span class="kw">&gt;</span>
<a id="cb1-141" class="sourceLine" title="141"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Gear<span class="kw">&lt;/span&gt;</span>
<a id="cb1-142" class="sourceLine" title="142"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Gaming<span class="kw">&lt;/span&gt;</span>
<a id="cb1-143" class="sourceLine" title="143"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Entertainment<span class="kw">&lt;/span&gt;</span>
<a id="cb1-144" class="sourceLine" title="144"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Tomorrow<span class="kw">&lt;/span&gt;</span>
<a id="cb1-145" class="sourceLine" title="145"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Video<span class="kw">&lt;/span&gt;</span>
<a id="cb1-146" class="sourceLine" title="146"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Reviews<span class="kw">&lt;/span&gt;</span>
<a id="cb1-147" class="sourceLine" title="147"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Events<span class="kw">&lt;/span&gt;</span>
<a id="cb1-148" class="sourceLine" title="148"></a>        <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Local Edition<span class="kw">&lt;/span&gt;</span>
<a id="cb1-149" class="sourceLine" title="149"></a>        <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"search"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>⌕<span class="kw">&lt;/span&gt;</span>
<a id="cb1-150" class="sourceLine" title="150"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-151" class="sourceLine" title="151"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"darkbox"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb1-152" class="sourceLine" title="152"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"content"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>
<a id="cb1-153" class="sourceLine" title="153"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;</span>
<a id="cb1-154" class="sourceLine" title="154"></a>          <span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">"popular"</span><span class="kw">&gt;</span>Popular Now<span class="kw">&lt;/p&gt;</span>
<a id="cb1-155" class="sourceLine" title="155"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-156" class="sourceLine" title="156"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-157" class="sourceLine" title="157"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-158" class="sourceLine" title="158"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-159" class="sourceLine" title="159"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-small"</span><span class="kw">&gt;</span>
<a id="cb1-160" class="sourceLine" title="160"></a>              Foods that boost your learning
<a id="cb1-161" class="sourceLine" title="161"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-162" class="sourceLine" title="162"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-163" class="sourceLine" title="163"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-164" class="sourceLine" title="164"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-165" class="sourceLine" title="165"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-166" class="sourceLine" title="166"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-167" class="sourceLine" title="167"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-168" class="sourceLine" title="168"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-small"</span><span class="kw">&gt;</span>
<a id="cb1-169" class="sourceLine" title="169"></a>              Robot arms may be the next
<a id="cb1-170" class="sourceLine" title="170"></a>              technological frontier
<a id="cb1-171" class="sourceLine" title="171"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-172" class="sourceLine" title="172"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-173" class="sourceLine" title="173"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-174" class="sourceLine" title="174"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-175" class="sourceLine" title="175"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-176" class="sourceLine" title="176"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-3.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-177" class="sourceLine" title="177"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-178" class="sourceLine" title="178"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-small"</span><span class="kw">&gt;</span>
<a id="cb1-179" class="sourceLine" title="179"></a>              Is virtual reality going to far?
<a id="cb1-180" class="sourceLine" title="180"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-181" class="sourceLine" title="181"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-182" class="sourceLine" title="182"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-183" class="sourceLine" title="183"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-184" class="sourceLine" title="184"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-185" class="sourceLine" title="185"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-small-4.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-186" class="sourceLine" title="186"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-187" class="sourceLine" title="187"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-small"</span><span class="kw">&gt;</span>
<a id="cb1-188" class="sourceLine" title="188"></a>              The latest trends in cosplay
<a id="cb1-189" class="sourceLine" title="189"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-190" class="sourceLine" title="190"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-191" class="sourceLine" title="191"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-192" class="sourceLine" title="192"></a>
<a id="cb1-193" class="sourceLine" title="193"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb1-194" class="sourceLine" title="194"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;</span>
<a id="cb1-195" class="sourceLine" title="195"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-196" class="sourceLine" title="196"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-197" class="sourceLine" title="197"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-big-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-198" class="sourceLine" title="198"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-199" class="sourceLine" title="199"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-large"</span><span class="kw">&gt;</span>
<a id="cb1-200" class="sourceLine" title="200"></a>              Before you buy, check our review of the
<a id="cb1-201" class="sourceLine" title="201"></a>              hottest cars on the market
<a id="cb1-202" class="sourceLine" title="202"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-203" class="sourceLine" title="203"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-204" class="sourceLine" title="204"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-205" class="sourceLine" title="205"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-206" class="sourceLine" title="206"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-207" class="sourceLine" title="207"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-big-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-208" class="sourceLine" title="208"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-209" class="sourceLine" title="209"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-large"</span><span class="kw">&gt;</span>
<a id="cb1-210" class="sourceLine" title="210"></a>              Health benefits of fresh fruits
<a id="cb1-211" class="sourceLine" title="211"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-212" class="sourceLine" title="212"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-213" class="sourceLine" title="213"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-214" class="sourceLine" title="214"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb1-215" class="sourceLine" title="215"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;</span>
<a id="cb1-216" class="sourceLine" title="216"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-217" class="sourceLine" title="217"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-218" class="sourceLine" title="218"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-medium-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-219" class="sourceLine" title="219"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-220" class="sourceLine" title="220"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-medium"</span><span class="kw">&gt;</span>
<a id="cb1-221" class="sourceLine" title="221"></a>              The best places to visit on Jupiter
<a id="cb1-222" class="sourceLine" title="222"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-223" class="sourceLine" title="223"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-224" class="sourceLine" title="224"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-225" class="sourceLine" title="225"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-226" class="sourceLine" title="226"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-227" class="sourceLine" title="227"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-medium-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-228" class="sourceLine" title="228"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-229" class="sourceLine" title="229"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-medium"</span><span class="kw">&gt;</span>
<a id="cb1-230" class="sourceLine" title="230"></a>              The latest smart watches monitor your
<a id="cb1-231" class="sourceLine" title="231"></a>              body's vitals while looking stylish
<a id="cb1-232" class="sourceLine" title="232"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-233" class="sourceLine" title="233"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-234" class="sourceLine" title="234"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-235" class="sourceLine" title="235"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb1-236" class="sourceLine" title="236"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb1-237" class="sourceLine" title="237"></a>              <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"32-medium-3.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-238" class="sourceLine" title="238"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-239" class="sourceLine" title="239"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline-medium"</span><span class="kw">&gt;</span>
<a id="cb1-240" class="sourceLine" title="240"></a>              Keeping yourself safe while shopping online
<a id="cb1-241" class="sourceLine" title="241"></a>            <span class="kw">&lt;/div&gt;</span>
<a id="cb1-242" class="sourceLine" title="242"></a>            <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 2 Hours<span class="kw">&lt;/div&gt;</span>
<a id="cb1-243" class="sourceLine" title="243"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-244" class="sourceLine" title="244"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb1-245" class="sourceLine" title="245"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-246" class="sourceLine" title="246"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"footer"</span><span class="kw">&gt;</span>Copyright 2018<span class="kw">&lt;/div&gt;</span>
<a id="cb1-247" class="sourceLine" title="247"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb1-248" class="sourceLine" title="248"></a>
<a id="cb1-249" class="sourceLine" title="249"></a>  <span class="kw">&lt;/body&gt;</span>
<a id="cb1-250" class="sourceLine" title="250"></a><span class="kw">&lt;/html&gt;</span></code></pre>
</div>
<h2 id="detailed-code-walkthrough">Detailed Code Walkthrough</h2>
<h3 id="setting-some-page-level-defaults">Setting Some Page Level Defaults</h3>
<div id="cb2" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb2-1" class="sourceLine" title="1"></a><span class="op">*</span> {
<a id="cb2-2" class="sourceLine" title="2"></a>  <span class="kw">box-sizing</span>: <span class="dv">border-box</span><span class="op">;</span>
<a id="cb2-3" class="sourceLine" title="3"></a>  <span class="kw">font-family</span>: <span class="dv">sans-serif</span><span class="op">;</span>
<a id="cb2-4" class="sourceLine" title="4"></a>  <span class="kw">font-size</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb2-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>The <span class="css-property">box-sizing</span> property<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a> is set to <span class="css-value">border-box</span> &#8211; instead of the default <span class="css-property">content-box</span> &#8211; for all elements. You almost always want to do this because it makes layout much easier.</p>
<p>The <span class="css-property">font-family</span> is set to <span class="css-value">sans-serif</span>, but you are free to choose <span class="css-value">serif</span> or <span class="css-value">monospace</span>.<a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a></p>
<p>The <span class="css-property">font-size</span> is set to <span class="css-value">16px</span>. This is the default value for almost all web browsers.</p>
<p>These settings will be applied to all the HTML elements unless overridden by more specific styling.<a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a></p>
<h3 id="the-highest-level-structure">The Highest Level Structure</h3>
<p>When writing the code, it became obvious that another element &#8211; which I call <strong>darkbox</strong> &#8211; was needed below the <strong>navbar</strong>.</p>
<p>It didn’t have to be added to the high level structure, it could have been nested inside the <strong>navbar</strong> &#8211; but it seemed simpler this way.</p>
<p>At the highest level, the (new) HTML structure looks like this:</p>
<div id="cb3" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb3-1" class="sourceLine" title="1"></a><span class="kw">&lt;body&gt;</span>
<a id="cb3-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"wrapper"</span><span class="kw">&gt;</span>
<a id="cb3-3" class="sourceLine" title="3"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"navbar"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-5" class="sourceLine" title="5"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"darkbox"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-6" class="sourceLine" title="6"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"content"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>
<a id="cb3-7" class="sourceLine" title="7"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-8" class="sourceLine" title="8"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-9" class="sourceLine" title="9"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-10" class="sourceLine" title="10"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb3-11" class="sourceLine" title="11"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"footer"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-12" class="sourceLine" title="12"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb3-13" class="sourceLine" title="13"></a><span class="kw">&lt;/body&gt;</span></code></pre>
</div>
<p>As we walk through the code, it should become clear why it was added.</p>
<h3 id="the-wrapper">The Wrapper</h3>
<p>The <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/sectioning-using-html-and-auto-centering-content/">standard way of laying out a webpage</a> is to add a content wrapper between the <span class="html-tag">body</span> tags rather than directly adding content to the <strong>body</strong> section of the document.</p>
<div id="cb4" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb4-1" class="sourceLine" title="1"></a><span class="kw">&lt;body&gt;</span>
<a id="cb4-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"wrapper"</span><span class="kw">&gt;</span>
<a id="cb4-3" class="sourceLine" title="3"></a>
<a id="cb4-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb4-5" class="sourceLine" title="5"></a><span class="kw">&lt;/body&gt;</span></code></pre>
</div>
<p>There is no change from the design decision to make the content 960px wide and to center it inside the <strong>body</strong> section by setting the margins to <span class="css-value">auto</span>:</p>
<div id="cb5" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb5-1" class="sourceLine" title="1"></a><span class="pp">#wrapper</span> {
<a id="cb5-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">960</span><span class="dt">px</span><span class="op">;</span>
<a id="cb5-3" class="sourceLine" title="3"></a>  <span class="kw">margin</span>: <span class="bu">auto</span><span class="op">;</span>
<a id="cb5-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<h3 id="the-title">The Title</h3>
<div id="cb6" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb6-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;</span>
<a id="cb6-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"site-name"</span><span class="kw">&gt;</span>clonage<span class="kw">&lt;/span&gt;</span>
<a id="cb6-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"login"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>Login<span class="kw">&lt;/span&gt;</span>
<a id="cb6-4" class="sourceLine" title="4"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>The <strong>Title</strong> section consists of a single line with two parts:</p>
<ol class="incremental" type="1">
<li>the site title</li>
<li>the login</li>
</ol>
<p>The <span class="html-tag">span</span> tag is used to style elements in a line.<a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a></p>
<p>We want one element to be to the left and one to the right. This can be accomplished by floating the <strong>login</strong> to the right.<a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a></p>
<p>A <span class="css-class">.clearfix</span> is applied to the final element to remove the effect of the float.<a id="fnref6" class="footnote-ref" href="#fn6"><sup>6</sup></a></p>
<div id="cb7" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb7-1" class="sourceLine" title="1"></a><span class="pp">#title</span> {
<a id="cb7-2" class="sourceLine" title="2"></a>  <span class="kw">background-color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb7-3" class="sourceLine" title="3"></a>  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb7-4" class="sourceLine" title="4"></a>  <span class="kw">padding</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb7-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>Some basic properties are set for the title area:</p>
<ul class="incremental">
<li>background colour,</li>
<li>text colour,</li>
<li>and a little bit of padding to make it look nice.</li>
</ul>
<div id="cb8" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb8-1" class="sourceLine" title="1"></a><span class="pp">#site-name</span> {
<a id="cb8-2" class="sourceLine" title="2"></a>  <span class="kw">font-size</span>: <span class="dv">32</span><span class="dt">px</span><span class="op">;</span>
<a id="cb8-3" class="sourceLine" title="3"></a>  <span class="kw">font-weight</span>: <span class="dv">bold</span><span class="op">;</span>
<a id="cb8-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<p>To make the site name stand out, the font size is set to 32px and made bold. You could also make the site name an image &#8211; this would allow you to use a logo as well.</p>
<p>The title could be floated to the left, but it left justifies automatically, so it is unnecessary. You can add <span class="css-property">float:</span><span class="css-value">left</span> to the class &#8211; if you want.</p>
<div id="cb9" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb9-1" class="sourceLine" title="1"></a><span class="pp">#login</span> {
<a id="cb9-2" class="sourceLine" title="2"></a>  <span class="kw">color</span>: <span class="cn">grey</span><span class="op">;</span>
<a id="cb9-3" class="sourceLine" title="3"></a>  <span class="kw">padding-top</span>: <span class="dv">8</span><span class="dt">px</span><span class="op">;</span>
<a id="cb9-4" class="sourceLine" title="4"></a>  <span class="kw">float</span>: <span class="dv">right</span><span class="op">;</span>
<a id="cb9-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>The <strong>login</strong> is subdued compared to the surrounding text, so it was set to <strong>grey</strong> instead of <strong>black</strong>. A custom hexadecimal RGB value could be used as well.</p>
<p>8px of padding was added to the top to vertically align the <strong>login</strong> text with the site name.<a id="fnref7" class="footnote-ref" href="#fn7"><sup>7</sup></a> If you wanted to adjust the <span class="css-property">margin</span> instead of the <span class="css-property">padding</span>, then the <span class="css-property">display</span> mode of the span must be changed to <span class="css-value">inline-block</span>.<a id="fnref8" class="footnote-ref" href="#fn8"><sup>8</sup></a></p>
<p>The HTML element was also floated to the right of the page.</p>
<h3 id="the-navigation-bar">The Navigation Bar</h3>
<div id="cb10" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb10-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"navbar"</span><span class="kw">&gt;</span>
<a id="cb10-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Gear<span class="kw">&lt;/span&gt;</span>
<a id="cb10-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Gaming<span class="kw">&lt;/span&gt;</span>
<a id="cb10-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Entertainment<span class="kw">&lt;/span&gt;</span>
<a id="cb10-5" class="sourceLine" title="5"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Tomorrow<span class="kw">&lt;/span&gt;</span>
<a id="cb10-6" class="sourceLine" title="6"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Video<span class="kw">&lt;/span&gt;</span>
<a id="cb10-7" class="sourceLine" title="7"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Reviews<span class="kw">&lt;/span&gt;</span>
<a id="cb10-8" class="sourceLine" title="8"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Events<span class="kw">&lt;/span&gt;</span>
<a id="cb10-9" class="sourceLine" title="9"></a>  <span class="kw">&lt;span</span><span class="ot"> class=</span><span class="st">nav-item</span><span class="kw">&gt;</span>Local Edition<span class="kw">&lt;/span&gt;</span>
<a id="cb10-10" class="sourceLine" title="10"></a>  <span class="kw">&lt;span</span><span class="ot"> id=</span><span class="st">"search"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>⌕<span class="kw">&lt;/span&gt;</span>
<a id="cb10-11" class="sourceLine" title="11"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Each menu or navigation item is enclosed inside a <span class="html-tag">span</span> element. This allows each item to be individually styled.<a id="fnref9" class="footnote-ref" href="#fn9"><sup>9</sup></a> Recall that HTML eliminates all excess whitespace characters.<a id="fnref10" class="footnote-ref" href="#fn10"><sup>10</sup></a></p>
<p>The element containing the “search” icon is given the id <strong>search</strong> since there should be only one search item on the page. It is floated to the right. A suitably sized image of a magnifying glass could have been used, instead similar looking text character is used instead &#8211; it is a <a href="https://www.compart.com/en/unicode/U+2315">“telephone recorder” (⌕)</a>. This simplifies everything by keeping everything text instead of mixing text and images (not that there is anything wrong with doing that). Finally, the <span class="css-class">.clearfix</span> is applied to clear the float.</p>
<div id="cb11" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb11-1" class="sourceLine" title="1"></a><span class="pp">#navbar</span> {
<a id="cb11-2" class="sourceLine" title="2"></a>  <span class="kw">background-color</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb11-3" class="sourceLine" title="3"></a>  <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb11-4" class="sourceLine" title="4"></a>  <span class="kw">border-bottom</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb11-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>The background is dark, but not black. A thin border is set on the bottom.</p>
<div id="cb12" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb12-1" class="sourceLine" title="1"></a><span class="fu">.nav-item</span> {
<a id="cb12-2" class="sourceLine" title="2"></a>  <span class="kw">display</span>: <span class="dv">inline-block</span><span class="op">;</span>
<a id="cb12-3" class="sourceLine" title="3"></a>  <span class="kw">padding</span>: <span class="dv">24</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb12-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<p>Each <span class="css-class">.nav-item</span> has <span class="css-property">display</span> set to <span class="css-value">inline-block</span>. This allows us full control of the margins (including the top and bottom).</p>
<p>The <span class="css-property">padding</span> is set to something I considered pleasing looking.</p>
<div id="cb13" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb13-1" class="sourceLine" title="1"></a><span class="pp">#search</span> {
<a id="cb13-2" class="sourceLine" title="2"></a>  <span class="kw">color</span>: <span class="cn">grey</span><span class="op">;</span>
<a id="cb13-3" class="sourceLine" title="3"></a>  <span class="kw">float</span>: <span class="dv">right</span><span class="op">;</span>
<a id="cb13-4" class="sourceLine" title="4"></a>  <span class="kw">padding-top</span>: <span class="dv">18</span><span class="dt">px</span><span class="op">;</span>
<a id="cb13-5" class="sourceLine" title="5"></a>  <span class="kw">padding-right</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb13-6" class="sourceLine" title="6"></a>  <span class="kw">font-size</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb13-7" class="sourceLine" title="7"></a>}</code></pre>
</div>
<p>The <strong>search</strong> element is floated to the right. The colour is a more muted and set to grey. Because the “telephone recorder” is a bit small, the font-size was increased to 24 px. This required adjusting the top padding to make it look centred.</p>
<h3 id="the-dark-box">The Dark Box</h3>
<p>This is the trickiest element and requires a bit of lateral thinking.</p>
<p>If you look at the original page layout, you see the columns overlap a dark region above them. You also notice that there is a vertical line dividing the columns and a horizontal line dividing the navigation bar from the columns:<a id="fnref11" class="footnote-ref" href="#fn11"><sup>11</sup></a><br />
<img fetchpriority="high" decoding="async" width="600" height="426" class="aligncenter size-full wp-image-3749" src="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min.jpg" alt="A screenshot of a website home page." srcset="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min.jpg 600w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min-300x213.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /><br />
The horizontal dividing line is made by setting the <span class="css-property">border-bottom</span> of the navbar container to something visible.</p>
<p>Placing an identically coloured element below the navigation bar, it looks like there is a horizontal line dividing the dark region into a top and bottom.</p>
<div id="cb14" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb14-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"darkbox"</span><span class="kw">&gt;&lt;/div&gt;</span></code></pre>
</div>
<p>The <span class="css-id">darkbox</span> is an empty <span class="html-tag">div</span> with some <span class="css-property">height</span> applied.</p>
<p>Perhaps a better name would be <strong>navbar-extension</strong> instead of <strong>darkbox</strong>.</p>
<div id="cb15" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb15-1" class="sourceLine" title="1"></a><span class="pp">#darkbox</span> {
<a id="cb15-2" class="sourceLine" title="2"></a>  <span class="kw">background-color</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb15-3" class="sourceLine" title="3"></a>  <span class="kw">height</span>: <span class="dv">100</span><span class="dt">px</span><span class="op">;</span>
<a id="cb15-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<p>The <span class="css-property">background-color</span> is set the same as for the <span class="css-id">navbar</span>.</p>
<p>A <span class="css-property">height</span> of 100px looks about the right size.</p>
<h3 id="the-content">The Content</h3>
<div id="cb16" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb16-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"content"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>
<a id="cb16-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb16-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb16-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb16-5" class="sourceLine" title="5"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>The <span class="css-id">content</span> is a container holding three left floating columns. It is styled with <span class="css-class">.clearfix</span> to restore normal flow. The <span class="css-class">.clearfix</span> could be applied only to <span class="css-class">.column-right</span>, but it seems better to clear at the parent container level.</p>
<div id="cb17" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb17-1" class="sourceLine" title="1"></a><span class="pp">#content</span> {
<a id="cb17-2" class="sourceLine" title="2"></a>  <span class="kw">margin-top</span>: <span class="dv">-90</span><span class="dt">px</span><span class="op">;</span>
<a id="cb17-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>The <span class="css-property">margin-top</span> is set to -90px. This causes the <span class="css-id">content</span> area to be shifted upwards 90px. This causes it to overlap the <span class="css-id">darkbox</span>. It is possible to use negative values for positioning elements.</p>
<h3 id="the-column-left">The column-left</h3>
<p>The <span class="css-class">.column-left</span> contains the title <strong>Popular</strong> and 4 cards.</p>
<div id="cb18" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb18-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;</span>
<a id="cb18-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">"popular"</span><span class="kw">&gt;</span>Popular Now<span class="kw">&lt;/p&gt;</span>
<a id="cb18-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb18-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb18-5" class="sourceLine" title="5"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb18-6" class="sourceLine" title="6"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb18-7" class="sourceLine" title="7"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>The <span class="css-class">.column-left</span> is styled to have a <span class="css-property">width</span> of 20% and to <span class="css-property">float</span> left.</p>
<div id="cb19" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb19-1" class="sourceLine" title="1"></a><span class="fu">.column-left</span> {
<a id="cb19-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">20</span><span class="dt">%</span><span class="op">;</span>
<a id="cb19-3" class="sourceLine" title="3"></a>  <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb19-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<p>The <strong>Popular</strong> title is styled using the <span class="css-id">#popular</span> class which sets the text <span class="css-property">color</span> to white, adds 16px of <span class="css-property">padding-left</span> to nicely align the title and set the <span class="css-property">font-weight</span> to bold so it stands out.</p>
<div id="cb20" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb20-1" class="sourceLine" title="1"></a><span class="pp">#popular</span> {
<a id="cb20-2" class="sourceLine" title="2"></a>  <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb20-3" class="sourceLine" title="3"></a>  <span class="kw">padding-left</span>: <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb20-4" class="sourceLine" title="4"></a>  <span class="kw">font-weight</span>: <span class="dv">bold</span><span class="op">;</span>
<a id="cb20-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>We will examine the details of the <span class="css-class">.card</span> class a little later.</p>
<h3 id="the-column-middle">The column-middle</h3>
<p>The <span class="css-class">.column-middle</span> consists of two cards.</p>
<div id="cb21" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb21-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;</span>
<a id="cb21-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb21-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb21-4" class="sourceLine" title="4"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>If you wanted to be more like the Verge website, which has a single large card and then two columns of cards beneath it, the code would look something like this this:</p>
<div id="cb22" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb22-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;</span>
<a id="cb22-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"dual-columns"</span><span class="kw">&gt;</span>  
<a id="cb22-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"dual-left"</span><span class="kw">&gt;</span>
<a id="cb22-5" class="sourceLine" title="5"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-6" class="sourceLine" title="6"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-7" class="sourceLine" title="7"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-8" class="sourceLine" title="8"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb22-9" class="sourceLine" title="9"></a>    <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"dual-right"</span><span class="kw">&gt;</span>
<a id="cb22-10" class="sourceLine" title="10"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-11" class="sourceLine" title="11"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-12" class="sourceLine" title="12"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-13" class="sourceLine" title="13"></a>    <span class="kw">&lt;/div&gt;</span>      
<a id="cb22-14" class="sourceLine" title="14"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb22-15" class="sourceLine" title="15"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>There might be better class names or you might want to use IDs instead of classes.</p>
<p>The <span class="css-class">.column-middle</span> is styled to have a <span class="css-property">width</span> of 55% and to <span class="css-property">float</span> left. It also has a thin border on the left and right side &#8211; this gives a nice visual esthetic. How could you make these vertical borders touch the horizontal border applied to the <span class="css-id">#navbar</span>?<a id="fnref12" class="footnote-ref" href="#fn12"><sup>12</sup></a></p>
<div id="cb23" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb23-1" class="sourceLine" title="1"></a><span class="fu">.column-middle</span> {
<a id="cb23-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">55</span><span class="dt">%</span><span class="op">;</span>
<a id="cb23-3" class="sourceLine" title="3"></a>  <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb23-4" class="sourceLine" title="4"></a>  <span class="kw">border-left</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb23-5" class="sourceLine" title="5"></a>  <span class="kw">border-right</span>: <span class="dv">2</span><span class="dt">px</span> <span class="dv">solid</span> <span class="cn">grey</span><span class="op">;</span>
<a id="cb23-6" class="sourceLine" title="6"></a>}</code></pre>
</div>
<h3 id="the-column-right">The column-right</h3>
<p>The <span class="css-class">.column-right</span> consists of three cards.</p>
<div id="cb24" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb24-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;</span>
<a id="cb24-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb24-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb24-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>  <span class="kw">&lt;/div&gt;</span>
<a id="cb24-5" class="sourceLine" title="5"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>The <span class="css-class">.column-right</span> is styled to have a <span class="css-property">width</span> of 25% and to <span class="css-property">float</span> left.</p>
<div id="cb25" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb25-1" class="sourceLine" title="1"></a><span class="fu">.column-right</span> {
<a id="cb25-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">25</span><span class="dt">%</span><span class="op">;</span>
<a id="cb25-3" class="sourceLine" title="3"></a>  <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb25-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<h3 id="the-card">The card</h3>
<p>A <span class="css-class">.card</span> encapsulates an:</p>
<ol class="incremental" type="1">
<li>image,</li>
<li>headline,</li>
<li>and timestamp .</li>
</ol>
<div id="cb26" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb26-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb26-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb26-3" class="sourceLine" title="3"></a>    <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"image.jpg"</span><span class="kw">&gt;</span>
<a id="cb26-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb26-5" class="sourceLine" title="5"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;</span>
<a id="cb26-6" class="sourceLine" title="6"></a>    A Headline
<a id="cb26-7" class="sourceLine" title="7"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb26-8" class="sourceLine" title="8"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;</span>🕔 A Timestamp<span class="kw">&lt;/div&gt;</span>
<a id="cb26-9" class="sourceLine" title="9"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>The <span class="html-tag">img</span> is wrapped inside a <span class="html-tag">div</span>. This is common practice.<a id="fnref13" class="footnote-ref" href="#fn13"><sup>13</sup></a> It allows the image and everything associated with the image to be encapsulated in its own container.</p>
<p>The <strong>headline</strong> contains some text. It could be wrapped inside a <span class="html-tag">p</span> tag, but it is not necessary.</p>
<p>The <strong>timestamp</strong> also contains some &#8211; which also could be wrapped inside a <span class="html-tag">p</span> tag. The clock (🕔) could be an image, but there are some Unicode clock characters<a id="fnref14" class="footnote-ref" href="#fn14"><sup>14</sup></a> &#8211; which what is used. It is easier to work with text instead of mixing text and images. However, whatever gets the job done is (usually) good.</p>
<p>The <span class="css-class">.card</span> is styled to have 16px of <span class="css-property">padding</span> on the left, right, and bottom. This padding allows the card to have some esthetic spacing on the sides and between cards. If 16px of padding were also applied to the top, then there would be 32px of spacing between the bottom of one card and the top of the next card.</p>
<div id="cb27" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb27-1" class="sourceLine" title="1"></a><span class="fu">.card</span> {
<a id="cb27-2" class="sourceLine" title="2"></a>  <span class="kw">padding</span>: <span class="dv">0</span> <span class="dv">16</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span> <span class="dv">16</span><span class="dt">px</span><span class="op">;</span>
<a id="cb27-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>The <span class="html-tag">img</span> tag is styled with a <span class="css-property">width</span> of 100%. This causes the image scale correctly to fit whatever container it is in &#8211; the same <span class="css-class">.card</span> is used in all the columns (20%, 55%, and 25%).<a id="fnref15" class="footnote-ref" href="#fn15"><sup>15</sup></a></p>
<div id="cb28" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb28-1" class="sourceLine" title="1"></a>img {
<a id="cb28-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb28-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>The wrapper for the [img]{html-tag} has the class <span class="css-class">.image</span> applied to it. At the moment, it doesn’t apply any styling, but it is available for modification in the future.<a id="fnref16" class="footnote-ref" href="#fn16"><sup>16</sup></a></p>
<div id="cb30" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb30-1" class="sourceLine" title="1"></a><span class="fu">.image</span> {
<a id="cb30-2" class="sourceLine" title="2"></a>
<a id="cb30-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<h3 id="the-footer">The footer</h3>
<p>The footer has its own ID and is styled to match the rest of the content on the page.</p>
<div id="cb31" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb31-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"footer"</span><span class="kw">&gt;</span>Copyright 2018<span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<div id="cb32" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb32-1" class="sourceLine" title="1"></a><span class="pp">#footer</span> {
<a id="cb32-2" class="sourceLine" title="2"></a>  <span class="kw">text-align</span>: <span class="dv">center</span><span class="op">;</span>
<a id="cb32-3" class="sourceLine" title="3"></a>  <span class="kw">padding</span>: <span class="dv">24</span><span class="dt">px</span><span class="op">;</span>
<a id="cb32-4" class="sourceLine" title="4"></a>  <span class="kw">background</span>: <span class="cn">#333333</span><span class="op">;</span>
<a id="cb32-5" class="sourceLine" title="5"></a>  <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb32-6" class="sourceLine" title="6"></a>  <span class="kw">font-size</span>: <span class="dv">20</span><span class="dt">px</span><span class="op">;</span>
<a id="cb32-7" class="sourceLine" title="7"></a>}</code></pre>
</div>
<h2 id="final-thoughts">Final Thoughts</h2>
<p>Using only what we’ve covered so far, it is possible to create quite sophisticated looking webpages.</p>
<p>You can go a step further and make the page “functional” by adding links to all the articles<a id="fnref17" class="footnote-ref" href="#fn17"><sup>17</sup></a> and creating the corresponding pages.</p>
<p>While it is a lot of work to create a webpage, it is not difficult work.</p>
<p>I encourage you to try and “clone” webpages from other sites. Remember, the goal is to practice and hone your skills, not to wear yourself out.</p>
<p>There is still a lot more to developing webpages and websites. Responsiveness[^responsive] is an important one: your webpage should look good on a 320px X 480px phone display as on a 1920px X 1080px desktop display. But this is something you don’t worry about in the beginning. First get the skills down to make pages that look good on the screen you are working on. In future lessons, we will look at how to make the page look good on varying display sizes.</p>
<h2 id="image-credits">Image Credits</h2>
<p>The images used in the example page are courtesy of:</p>
<ol class="incremental" type="1">
<li>Apple and Books by <a href="https://pixabay.com/en/apple-red-delicious-fruit-256263/">jarmoluk</a></li>
<li>Robotic Arm by <a href="https://pixabay.com/en/cybernetics-robot-robot-arm-1869205/">PIRO4D</a></li>
<li>Virtual Reality Cyclist by <a href="https://pixabay.com/en/augmented-reality-bicycle-bike-1853592/">VR Pexels</a></li>
<li>Cosplay Girl by <a href="https://pixabay.com/en/girl-portrait-bokeh-model-skin-2941823/">ptksgc</a></li>
<li>Toy Cars by <a href="https://pixabay.com/en/toys-hot-wheels-porsche-panamera-3582278/">kamal1118</a></li>
<li>Fruit Salad by <a href="https://pixabay.com/en/fruit-fruits-fruit-salad-fresh-bio-2305192/">silviarita</a></li>
<li>Astronaut and Jupiter by <a href="https://pixabay.com/en/cave-jupiter-astronaut-space-912219/">DasWortgewand</a></li>
<li>Watch by <a href="https://pixabay.com/en/watch-basketball-sport-active-1663246/">the5th</a></li>
<li>Keyboard by <a href="https://pixabay.com/en/shopping-keyboard-enter-button-3696867/">atthree23</a></li>
</ol>
<div class="prev">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-2/">Prev</a></p>
</div>
<div class="next">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/a-quick-introduction-to-two-development-tools-built-into-your-browser/">Next</a></p>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr>
<ol>
<li id="fn1">This was covered in <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/nine-more-css-properties-to-play-with/#box-sizing">None More CSS Properties to Play With</a><a class="footnote-back" href="#fnref1">↩</a></li>
<li id="fn2">A future tutorial will show how to use specific fonts like: Arial, Courier, Times New Roman, etc.<a class="footnote-back" href="#fnref2">↩</a></li>
<li id="fn3">A future tutorial will explore how CSS properties are applied when the same property is styled differently in multiple rules. This can happen when two or more classes are applied to the same element (or and ID and a class).<a class="footnote-back" href="#fnref3">↩</a></li>
<li id="fn4">This was covered in <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/sectioning-using-html-and-auto-centering-content/#span">Sectioning Using HTML and Auto Centering Content</a>. I could have floated the title to the left and the login to the right, but it wasn’t necessary. This is a design decision. You are free to float the title to the left.<a class="footnote-back" href="#fnref4">↩</a></li>
<li id="fn5">See <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2/#floated-elements-flow-sideways">CSS &#8211; Understanding How Float Works &#8211; Part 2</a><a class="footnote-back" href="#fnref5">↩</a></li>
<li id="fn6">See <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-1/#clearfix---the-better-way-to-clear-a-float">CSS – Understanding How Float Works – Part 1</a> for a discussion of <strong>clearfix</strong>.<a class="footnote-back" href="#fnref6">↩</a></li>
<li id="fn7">The site is set to 32px, and the default text size is set to 16px. This means the default text is 16px smaller than the site name. This is divided between the top and bottom of the <strong>login</strong> (or 8px on the top and 8px on the bottom). We know that floats move up as far as they can, so it is only necessary to add 8px of padding to the top. You can also use trial and error until it looks the way you want.<a class="footnote-back" href="#fnref7">↩</a></li>
<li id="fn8">This was discussed in <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/html-flow-and-the-css-box-model-the-display-property/#inline-block">HTML Flow and the CSS Box Model – the ‘Display’ Property</a><a class="footnote-back" href="#fnref8">↩</a></li>
<li id="fn9">It is more common to use an unordered list (<span class="html-tag">ul</span>) and make each element a list item (<span class="html-tag">li</span>). The list items are styled with <span class="css-property">display</span>:<span class="css-value">inline</span> instead of the default <span class="css-property">display</span>:<span class="css-value">list-item</span>. This requires using a property I haven’t discussed yet: <span class="css-property">list-style-type</span> which controls what is displayed next to each list item. Some of the values are: <span class="css-value">disc</span>, <span class="css-value">circle</span>, <span class="css-value">square</span>, <span class="css-value">none</span>. If you want to use a list instead, then apply <span class="css-property">list-style-type</span>:<span class="css-value">none</span> to the unordered list.<a class="footnote-back" href="#fnref9">↩</a></li>
<li id="fn10">See <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/html-basic-conclusion/#an-overview-of-html">HTML Basics – Conclusion</a><a class="footnote-back" href="#fnref10">↩</a></li>
<li id="fn11">OK, the lines are not so visible in the tiny little image I provide, but they are visible if you go to the engadget website.<a class="footnote-back" href="#fnref11">↩</a></li>
<li id="fn12">You move the content area up 100px &#8211; the full height of the <span class="css-id">#darkbox</span> &#8211; instead of 90px. You then add a bit of padding (maybe 10px) to the top of the content area so there is some spacing between the content and the horizontal line.<a class="footnote-back" href="#fnref12">↩</a></li>
<li id="fn13">Common practices, are often called <strong>design patterns</strong>. A <strong>design pattern</strong> is a generic solution for problems that repeatedly come up in software engineering. There are many different types of <strong>design patterns</strong>.<a class="footnote-back" href="#fnref13">↩</a></li>
<li id="fn14">Some of the available Unicode time characters are:
<div style="font-size: 32px;">
<style> .this-page {margin:0 !important;line-height:32px;} .this-span {font-size:16px;}</style>
<p class="this-page">⏰ &#8211; <span class="this-span">Alarm Clock</span></p>
<p class="this-page">🕰 &#8211; <span class="this-span">Mantelpiece Clock</span></p>
<p class="this-page">⌚ &#8211; <span class="this-span">Watch</span></p>
<p class="this-page">⏱ &#8211; <span class="this-span">Stopwatch</span></p>
<p class="this-page">⏲ &#8211; <span class="this-span">Timer</span></p>
<p class="this-page">⌛ &#8211; <span class="this-span">Hourglass</span></p>
<p class="this-page">⏳- <span class="this-span">Hourglass with flowing sand</span></p>
<p class="this-page">⧗ &#8211; <span class="this-span">Black Hourglass</span></p>
<p class="this-page">⧖ &#8211; <span class="this-span">White Hourglass</span></p>
<p class="this-page">🕛 &#8211; <span class="this-span">12:00</span></p>
<p class="this-page">🕧 &#8211; <span class="this-span">12:30</span></p>
<p class="this-page">🕐 &#8211; <span class="this-span">1:00</span></p>
<p class="this-page">🕜 &#8211; <span class="this-span">1:30</span></p>
<p class="this-page">🕑 &#8211; <span class="this-span">2:00</span></p>
<p class="this-page">🕝 &#8211; <span class="this-span">2:30</span></p>
<p class="this-page">🕒 &#8211; <span class="this-span">3:00</span></p>
<p class="this-page">🕞 &#8211; <span class="this-span">3:30</span></p>
<p class="this-page">🕓 &#8211; <span class="this-span">4:00</span></p>
<p class="this-page">🕟 &#8211; <span class="this-span">4:30</span></p>
<p class="this-page">🕔 &#8211; <span class="this-span">5:00</span></p>
<p class="this-page">🕠 &#8211; <span class="this-span">5:30</span></p>
<p class="this-page">🕕 &#8211; <span class="this-span">6:00</span></p>
<p class="this-page">🕡 &#8211; <span class="this-span">6:30</span></p>
<p class="this-page">🕖 &#8211; <span class="this-span">7:00</span></p>
<p class="this-page">🕢 &#8211; <span class="this-span">7:30</span></p>
<p class="this-page">🕗 &#8211; <span class="this-span">8:00</span></p>
<p class="this-page">🕣 &#8211; <span class="this-span">8:30</span></p>
<p class="this-page">🕘 &#8211; <span class="this-span">9:00</span></p>
<p class="this-page">🕤 &#8211; <span class="this-span">9:30</span></p>
<p class="this-page">🕙 &#8211; <span class="this-span">10:00</span></p>
<p class="this-page">🕥 &#8211; <span class="this-span">10:30</span></p>
<p class="this-page">🕚 &#8211; <span class="this-span">11:00</span></p>
<p class="this-page">🕦 &#8211; <span class="this-span">11:30</span></p>
</div>
<p><a class="footnote-back" href="#fnref14">↩</a></li>
<li id="fn15">This was covered in <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/nine-more-css-properties-to-play-with/#width-and-the-img-tag">Nine More CSS Properties to Play With</a><a class="footnote-back" href="#fnref15">↩</a></li>
<li id="fn16">You could argue that if there is no styling being applied, the class <span class="css-class">.image</span> shouldn’t exist. It is difficult to always know what is needed or what sort of changed might be made in the future. Having the class allows you to add a border or background colour. It is common to see unique empty classes applied to certain elements on a page for future styling. For example, you could add a unique paragraph class to each <span class="html-tag">p</span>:
<div id="cb29" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb29-1" class="sourceLine" title="1"></a><span class="kw">&lt;p</span><span class="ot"> class=</span><span class="st">"par-1234"</span><span class="kw">&gt;</span>Some text<span class="kw">&lt;/p&gt;</span>
<a id="cb29-2" class="sourceLine" title="2"></a><span class="kw">&lt;p</span><span class="ot"> class=</span><span class="st">"par-1235"</span><span class="kw">&gt;</span>Some other text<span class="kw">&lt;/p&gt;</span></code></pre>
</div>
<p>This allows you to change the appearance of individual paragraphs at a future date without having to change the HTML code &#8211; just the CSS. This can be applied to images, or other blocks of text.<a class="footnote-back" href="#fnref16">↩</a></li>
<li id="fn17">There is complexity in adding links to the articles. By default, anchored text, has a different default colour from surrounding text, hovering a mouse over the link unlerlines the link, a previously visited link has a different colour. You can style the <span class="html-tag">a</span> tag, but the options are more restricted (for security reasons).When <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-1/#clearfix---the-better-way-to-clear-a-float">.clearfix was discussed</a>, you saw the <span class="css-pseudo-element">::after</span> pseudo element selector. CSS has other selectors as well. The most commonly used with anchor tags are: <span class="css-selector">:hover</span> for styling when the mouse is over the content and <span class="css-selector">:visited</span> which allows styling visited links. You are free to experiment with them now, but they will be covered in a future tutorial.
<p>To disable underlining when hovering over a link, you would apply the following style:</p>
<div id="cb33" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb33-1" class="sourceLine" title="1"></a>a<span class="in">:hover</span> {
<a id="cb33-2" class="sourceLine" title="2"></a>  <span class="kw">text-decoration</span>: <span class="dv">none</span><span class="op">;</span>
<a id="cb33-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p><a class="footnote-back" href="#fnref17">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-3/">CSS &#8211; A More Advanced Float Example: Part 3</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; A More Advanced Float Example: Part 2</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-2/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Tue, 08 Jan 2019 14:36:01 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3759</guid>

					<description><![CDATA[<p>Having our project in mind, we break it down into the components that we need to think about as we code the page.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-2/">CSS &#8211; A More Advanced Float Example: Part 2</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
<p>Every complicated task needs to be broken down into smaller, simpler tasks.</p>
<p>Here we define the general structure before filling in the details in the next tutorial.</p>
</div>
<h2>Contents</h2>
<ol class="incremental" type="1">
<li><a href="#deciding-on-the-overall-structure">Deciding on the Overall Structure</a></li>
<li><a href="#a-skeleton-to-work-with">A Skeleton to Work With</a>
<ol class="incremental" type="1">
<li><a href="#id-styles-in-more-detail">ID Styles in More Detail</a>
<ol class="incremental" type="1">
<li><a href="#wrapper">#wrapper</a></li>
<li><a href="#title">#title</a></li>
<li><a href="#navbar">#navbar</a></li>
<li><a href="#content">#content</a></li>
<li><a href="#footer">#footer</a></li>
</ol>
</li>
<li><a href="#class-styles-in-more-detail">Class Styles in More Detail</a>
<ol class="incremental" type="1">
<li><a href="#column">.column</a></li>
<li><a href="#clearfix">.clearfix</a></li>
</ol>
</li>
<li><a href="#the-html-in-more-detail">The HTML in More Detail</a></li>
</ol>
</li>
<li><a href="#cards">Cards</a></li>
</ol>
<h2 id="deciding-on-the-overall-structure">Deciding on the Overall Structure</h2>
<p>When we examine the <a href="https://engadget.com">engadget</a> website:</p>
<p><img decoding="async" class="aligncenter size-full wp-image-3749" src="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min.jpg" alt="A screenshot of a website home page." width="600" height="426" srcset="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min.jpg 600w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min-300x213.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>we see that its general structure looks something like this:</p>
<p><img decoding="async" class="aligncenter size-full wp-image-3761" src="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-min.png" alt="High level overview of the page layout" width="600" height="375" srcset="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-min.png 600w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-min-300x188.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>It consists of 6 rectangles:</p>
<ul class="incremental">
<li>2 stacked one atop the other at the top</li>
<li>3 stacked side-by-side in the middle</li>
<li>1 at the bottom of the page</li>
</ul>
<p>It should be obvious that the 3 side-by-side columns are positioned using <span class="css-property">float</span>.</p>
<p>Estimating the columns widths, it looks like:</p>
<ul class="incremental">
<li>the narrowest column occupies about 20% of the display</li>
<li>the widest column occupies about 50% of the display</li>
<li>this leaves 30% for the medium width column</li>
</ul>
<p>This is a rough guess, but it is a starting point. As we refine the page, we may adjust the relative widths of the columns to make the layout appear more pleasing.</p>
<p>I will make the content section 960px wide.<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a> I previously mentioned that 960px is a good rule of thumb for the content width of a webpage<a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a></p>
<h2 id="a-skeleton-to-work-with">A Skeleton to Work With</h2>
<p>A rough page skeleton might look something like this:</p>
<div id="cb1" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb1-1" class="sourceLine" title="1"></a><span class="dt">&lt;!DOCTYPE </span>HTML<span class="dt">&gt;</span>
<a id="cb1-2" class="sourceLine" title="2"></a><span class="kw">&lt;html&gt;</span>
<a id="cb1-3" class="sourceLine" title="3"></a>  <span class="kw">&lt;head&gt;</span>
<a id="cb1-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;title&gt;</span>Rough Layout<span class="kw">&lt;/title&gt;</span>
<a id="cb1-5" class="sourceLine" title="5"></a>    <span class="kw">&lt;meta</span><span class="ot"> charset=</span><span class="st">"utf-8"</span>  <span class="kw">/&gt;</span>
<a id="cb1-6" class="sourceLine" title="6"></a>
<a id="cb1-7" class="sourceLine" title="7"></a>    <span class="kw">&lt;style&gt;</span>
<a id="cb1-8" class="sourceLine" title="8"></a>
<a id="cb1-9" class="sourceLine" title="9"></a>      <span class="pp">#wrapper</span> {
<a id="cb1-10" class="sourceLine" title="10"></a>        <span class="kw">width</span>: <span class="dv">960</span><span class="dt">px</span><span class="op">;</span>
<a id="cb1-11" class="sourceLine" title="11"></a>        <span class="kw">margin</span>: <span class="bu">auto</span><span class="op">;</span>
<a id="cb1-12" class="sourceLine" title="12"></a>      }
<a id="cb1-13" class="sourceLine" title="13"></a>
<a id="cb1-14" class="sourceLine" title="14"></a>      <span class="pp">#title</span> {
<a id="cb1-15" class="sourceLine" title="15"></a>        <span class="kw">background-color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-16" class="sourceLine" title="16"></a>        <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb1-17" class="sourceLine" title="17"></a>        <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-18" class="sourceLine" title="18"></a>      }
<a id="cb1-19" class="sourceLine" title="19"></a>
<a id="cb1-20" class="sourceLine" title="20"></a>      <span class="pp">#navbar</span> {
<a id="cb1-21" class="sourceLine" title="21"></a>        <span class="kw">background-color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb1-22" class="sourceLine" title="22"></a>        <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb1-23" class="sourceLine" title="23"></a>        <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-24" class="sourceLine" title="24"></a>      }
<a id="cb1-25" class="sourceLine" title="25"></a>
<a id="cb1-26" class="sourceLine" title="26"></a>      <span class="pp">#content</span> {
<a id="cb1-27" class="sourceLine" title="27"></a>        <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-28" class="sourceLine" title="28"></a>      }
<a id="cb1-29" class="sourceLine" title="29"></a>
<a id="cb1-30" class="sourceLine" title="30"></a>      <span class="pp">#footer</span> {
<a id="cb1-31" class="sourceLine" title="31"></a>        <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-32" class="sourceLine" title="32"></a>      }
<a id="cb1-33" class="sourceLine" title="33"></a>
<a id="cb1-34" class="sourceLine" title="34"></a>      <span class="fu">.column-left</span> {
<a id="cb1-35" class="sourceLine" title="35"></a>        <span class="kw">width</span>: <span class="dv">20</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-36" class="sourceLine" title="36"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb1-37" class="sourceLine" title="37"></a>      }
<a id="cb1-38" class="sourceLine" title="38"></a>
<a id="cb1-39" class="sourceLine" title="39"></a>      <span class="fu">.column-middle</span> {
<a id="cb1-40" class="sourceLine" title="40"></a>        <span class="kw">width</span>: <span class="dv">50</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-41" class="sourceLine" title="41"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb1-42" class="sourceLine" title="42"></a>      }
<a id="cb1-43" class="sourceLine" title="43"></a>
<a id="cb1-44" class="sourceLine" title="44"></a>      <span class="fu">.column-right</span> {
<a id="cb1-45" class="sourceLine" title="45"></a>        <span class="kw">width</span>: <span class="dv">30</span><span class="dt">%</span><span class="op">;</span>
<a id="cb1-46" class="sourceLine" title="46"></a>        <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb1-47" class="sourceLine" title="47"></a>      }
<a id="cb1-48" class="sourceLine" title="48"></a>
<a id="cb1-49" class="sourceLine" title="49"></a>      <span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb1-50" class="sourceLine" title="50"></a>        <span class="kw">clear</span>: <span class="dv">both</span><span class="op">;</span>
<a id="cb1-51" class="sourceLine" title="51"></a>        <span class="kw">display</span>: <span class="dv">block</span><span class="op">;</span>
<a id="cb1-52" class="sourceLine" title="52"></a>        <span class="kw">content</span>: <span class="st">""</span><span class="op">;</span>
<a id="cb1-53" class="sourceLine" title="53"></a>      }
<a id="cb1-54" class="sourceLine" title="54"></a>
<a id="cb1-55" class="sourceLine" title="55"></a>    <span class="kw">&lt;/style&gt;</span>
<a id="cb1-56" class="sourceLine" title="56"></a>  <span class="kw">&lt;/head&gt;</span>
<a id="cb1-57" class="sourceLine" title="57"></a>  <span class="kw">&lt;body&gt;</span>
<a id="cb1-58" class="sourceLine" title="58"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"wrapper"</span><span class="kw">&gt;</span>
<a id="cb1-59" class="sourceLine" title="59"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;</span>Title and Login<span class="kw">&lt;/div&gt;</span>
<a id="cb1-60" class="sourceLine" title="60"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"navbar"</span><span class="kw">&gt;</span>Navigation Bar and Search<span class="kw">&lt;/div&gt;</span>
<a id="cb1-61" class="sourceLine" title="61"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"content"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>
<a id="cb1-62" class="sourceLine" title="62"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;</span>Narrowest Column<span class="kw">&lt;/div&gt;</span>
<a id="cb1-63" class="sourceLine" title="63"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;</span>Widest Column<span class="kw">&lt;/div&gt;</span>
<a id="cb1-64" class="sourceLine" title="64"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;</span>Medium Width Column<span class="kw">&lt;/div&gt;</span>
<a id="cb1-65" class="sourceLine" title="65"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-66" class="sourceLine" title="66"></a>      <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"footer"</span><span class="kw">&gt;</span>The Footer<span class="kw">&lt;/div&gt;</span>
<a id="cb1-67" class="sourceLine" title="67"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb1-68" class="sourceLine" title="68"></a>
<a id="cb1-69" class="sourceLine" title="69"></a>  <span class="kw">&lt;/body&gt;</span>
<a id="cb1-70" class="sourceLine" title="70"></a><span class="kw">&lt;/html&gt;</span></code></pre>
</div>
<p>The rough layout consists of 5 ID styles and 4 class styles.</p>
<h3 id="id-styles-in-more-detail">ID Styles in More Detail</h3>
<p>If you remember, each ID must be unique<a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a> on the page and each HTML element can have only one ID.<a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a></p>
<p>IDs are used to refer to elements that the should only ever be one of on the page.</p>
<h4 id="wrapper">#wrapper</h4>
<div id="cb2" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb2-1" class="sourceLine" title="1"></a><span class="pp">#wrapper</span> {
<a id="cb2-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">960</span><span class="dt">px</span><span class="op">;</span>
<a id="cb2-3" class="sourceLine" title="3"></a>  <span class="kw">margin</span>: <span class="bu">auto</span><span class="op">;</span>
<a id="cb2-4" class="sourceLine" title="4"></a>}</code></pre>
</div>
<p>Because we are restricting the content width to 960px, we need to wrap all the content in a container that is 960px wide. We also set the <span class="css-property">margin</span> to <span class="css-value">auto</span> so the browser will automatically horizontally center the container in the browser window.<a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a></p>
<p>All other elements are styled to occupy the full width of the <strong>#wrapper</strong> by setting their width to 100%.<a id="fnref6" class="footnote-ref" href="#fn6"><sup>6</sup></a> By using percentages for all other element dimensions, we can change the content width by altering a single value in <strong>#wrapper</strong> instead of having to change it everywhere we use <strong>px</strong>.</p>
<h4 id="title">#title</h4>
<div id="cb3" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb3-1" class="sourceLine" title="1"></a><span class="pp">#title</span> {
<a id="cb3-2" class="sourceLine" title="2"></a>  <span class="kw">background-color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb3-3" class="sourceLine" title="3"></a>  <span class="kw">color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb3-4" class="sourceLine" title="4"></a>  <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb3-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>There should only be one <strong>title</strong> section on a page. We set the background to white (but you can make it any colour you like, you can be creative in your reimagining of the page).</p>
<h4 id="navbar">#navbar</h4>
<div id="cb4" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb4-1" class="sourceLine" title="1"></a><span class="pp">#navbar</span> {
<a id="cb4-2" class="sourceLine" title="2"></a>  <span class="kw">background-color</span>: <span class="cn">black</span><span class="op">;</span>
<a id="cb4-3" class="sourceLine" title="3"></a>  <span class="kw">color</span>: <span class="cn">white</span><span class="op">;</span>
<a id="cb4-4" class="sourceLine" title="4"></a>  <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb4-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>There should be only one <strong>navbar</strong> on a page. The background is set to black (but you can make it a different colour if you like). The text colour is set to white so it contrasts against the black background.</p>
<h4 id="content">#content</h4>
<div id="cb5" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb5-1" class="sourceLine" title="1"></a><span class="pp">#content</span> {
<a id="cb5-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb5-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>There should be only one <strong>content</strong> section (even if though it contains 3 columns).</p>
<h4 id="footer">#footer</h4>
<div id="cb6" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb6-1" class="sourceLine" title="1"></a><span class="pp">#footer</span> {
<a id="cb6-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">100</span><span class="dt">%</span><span class="op">;</span>
<a id="cb6-3" class="sourceLine" title="3"></a>}</code></pre>
</div>
<p>There should be only one <strong>footer</strong> on a page.</p>
<h3 id="class-styles-in-more-detail">Class Styles in More Detail</h3>
<h4 id="column">.column</h4>
<div id="cb7" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb7-1" class="sourceLine" title="1"></a><span class="fu">.column-left</span> {
<a id="cb7-2" class="sourceLine" title="2"></a>  <span class="kw">width</span>: <span class="dv">20</span><span class="dt">%</span><span class="op">;</span>
<a id="cb7-3" class="sourceLine" title="3"></a>  <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb7-4" class="sourceLine" title="4"></a>}
<a id="cb7-5" class="sourceLine" title="5"></a>
<a id="cb7-6" class="sourceLine" title="6"></a><span class="fu">.column-middle</span> {
<a id="cb7-7" class="sourceLine" title="7"></a>  <span class="kw">width</span>: <span class="dv">50</span><span class="dt">%</span><span class="op">;</span>
<a id="cb7-8" class="sourceLine" title="8"></a>  <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb7-9" class="sourceLine" title="9"></a>}
<a id="cb7-10" class="sourceLine" title="10"></a>
<a id="cb7-11" class="sourceLine" title="11"></a><span class="fu">.column-right</span> {
<a id="cb7-12" class="sourceLine" title="12"></a>  <span class="kw">width</span>: <span class="dv">30</span><span class="dt">%</span><span class="op">;</span>
<a id="cb7-13" class="sourceLine" title="13"></a>  <span class="kw">float</span>: <span class="dv">left</span><span class="op">;</span>
<a id="cb7-14" class="sourceLine" title="14"></a>}</code></pre>
</div>
<p>Because we have 3 unique columns, they could have been made IDs. I decided to make them classes because if I decide to go with a 4 column or 5 column layout, I might be able to reuse existing classes (I could have named the columns better).</p>
<p>They are all floated left and have their widths set as a percentage totaling 100%.</p>
<h4 id="clearfix">.clearfix</h4>
<div id="cb8" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb8-1" class="sourceLine" title="1"></a><span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb8-2" class="sourceLine" title="2"></a>  <span class="kw">clear</span>: <span class="dv">both</span><span class="op">;</span>
<a id="cb8-3" class="sourceLine" title="3"></a>  <span class="kw">display</span>: <span class="dv">block</span><span class="op">;</span>
<a id="cb8-4" class="sourceLine" title="4"></a>  <span class="kw">content</span>: <span class="st">""</span><span class="op">;</span>
<a id="cb8-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>The <strong>clearfix</strong> for the <strong>#content</strong> could have been written as:</p>
<div id="cb9" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb9-1" class="sourceLine" title="1"></a><span class="pp">#content</span><span class="in">::after</span> {
<a id="cb9-2" class="sourceLine" title="2"></a>  <span class="kw">clear</span>: <span class="dv">both</span><span class="op">;</span>
<a id="cb9-3" class="sourceLine" title="3"></a>  <span class="kw">display</span>: <span class="dv">block</span><span class="op">;</span>
<a id="cb9-4" class="sourceLine" title="4"></a>  <span class="kw">content</span>: <span class="st">""</span><span class="op">;</span>
<a id="cb9-5" class="sourceLine" title="5"></a>}</code></pre>
</div>
<p>But, we may find ourselves using <span class="css-property">float</span> in more places as we refine the page, so it is better to have it as a generic <strong>clearfix</strong> that can be applied as needed.</p>
<h3 id="the-html-in-more-detail">The HTML in More Detail</h3>
<div id="cb10" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb10-1" class="sourceLine" title="1"></a><span class="kw">&lt;body&gt;</span>
<a id="cb10-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"wrapper"</span><span class="kw">&gt;</span>
<a id="cb10-3" class="sourceLine" title="3"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;</span>Title and Login<span class="kw">&lt;/div&gt;</span>
<a id="cb10-4" class="sourceLine" title="4"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"navbar"</span><span class="kw">&gt;</span>Navigation Bar and Search<span class="kw">&lt;/div&gt;</span>
<a id="cb10-5" class="sourceLine" title="5"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"content"</span><span class="ot"> class=</span><span class="st">"clearfix"</span><span class="kw">&gt;</span>
<a id="cb10-6" class="sourceLine" title="6"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-left"</span><span class="kw">&gt;</span>Narrowest Column<span class="kw">&lt;/div&gt;</span>
<a id="cb10-7" class="sourceLine" title="7"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-middle"</span><span class="kw">&gt;</span>Widest Column<span class="kw">&lt;/div&gt;</span>
<a id="cb10-8" class="sourceLine" title="8"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"column-right"</span><span class="kw">&gt;</span>Medium Width Column<span class="kw">&lt;/div&gt;</span>
<a id="cb10-9" class="sourceLine" title="9"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb10-10" class="sourceLine" title="10"></a>    <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">"footer"</span><span class="kw">&gt;</span>The Footer<span class="kw">&lt;/div&gt;</span>
<a id="cb10-11" class="sourceLine" title="11"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb10-12" class="sourceLine" title="12"></a>
<a id="cb10-13" class="sourceLine" title="13"></a><span class="kw">&lt;/body&gt;</span></code></pre>
</div>
<p>It should be straightforward:</p>
<ul class="incremental">
<li>the <span class="css-id">#wrapper</span> encloses all the other html</li>
<li>the <span class="css-id">#title</span>, <span class="css-id">#navbar</span>, <span class="css-id">#content</span>, and <span class="css-id">#footer</span> stack one atop the other in <strong>normal flow</strong></li>
<li>the <strong>columns</strong> are left floated inside the #content</li>
</ul>
<h2 id="cards">Cards</h2>
<p>Having completed the basic structure, we can now focus on some of the internal details.</p>
<p>Each column contains a number of stacked cards containing information about the article. Each card contains:</p>
<ol class="incremental" type="1">
<li>An image</li>
<li>A title</li>
<li>A timestamp</li>
</ol>
<p>The HTML should look something like this:</p>
<div id="cb11" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb11-1" class="sourceLine" title="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"card"</span><span class="kw">&gt;</span>
<a id="cb11-2" class="sourceLine" title="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"image"</span><span class="kw">&gt;</span>
<a id="cb11-3" class="sourceLine" title="3"></a>    <span class="kw">&lt;img&gt;</span>
<a id="cb11-4" class="sourceLine" title="4"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb11-5" class="sourceLine" title="5"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"headline"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb11-6" class="sourceLine" title="6"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"timestamp"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb11-7" class="sourceLine" title="7"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>It should be straightforward:</p>
<ul class="incremental">
<li>a card consists of a wrapper which I call <span class="css-class">card</span></li>
<li>inside the card wrapper we have the <span class="css-class">image</span>, the article <span class="css-class">headline</span>, and the <span class="css-class">timestamp</span></li>
<li>the actual image is placed inside an <span class="css-class">image</span> container because the image only has a single tag and it is easier to manipulate if we place it inside a <span class="html-tag">div</span> element.<a id="fnref7" class="footnote-ref" href="#fn7"><sup>7</sup></a></li>
</ul>
<p>And with some styling it could look something like this:</p>
<div style="width: 240px; background: white; margin: auto;">
<div class="card">
<div class="image"><img loading="lazy" decoding="async" width="960" height="635" class="aligncenter size-full wp-image-3762" src="https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-small-1.jpg" alt="An apple sitting on top of books resting atop a desk." srcset="https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-small-1.jpg 960w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-small-1-300x198.jpg 300w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-small-1-768x508.jpg 768w" sizes="auto, (max-width: 960px) 100vw, 960px" /></div>
<div class="headline-small">Foods that boost your learning</div>
<div class="timestamp">🕔 2 Hours</div>
</div>
</div>
<div class="prev">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-1/">Prev</a></p>
</div>
<div class="next">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-3/">Next</a></p>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr>
<ol>
<li id="fn1">If you are curious, the engadget content is 1275px wide. The narrowest column is 255px, the widest column is 680px, and the medium width column is 340px. Corresponding to column widths of 20%, 53.3%, and 26.7% respectively.<a href="#fnref1" class="footnote-back">↩</a></li>
<li id="fn2">See note 4 in the tutorial <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2/#playing-around">CSS – Understanding How Float Works – Part 2</a>. It’s a good rule of thumb for desktop webpages because it will render correctly on most desktop browsers.<a href="#fnref2" class="footnote-back">↩</a></li>
<li id="fn3">This was covered in the article <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-selecting-specific-elements-for-styling/#id-selector">CSS &#8211; Selecting Specific Elements for Styling</a>.<a href="#fnref3" class="footnote-back">↩</a></li>
<li id="fn4">This was mentioned in a footnote in the article <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-selecting-specific-elements-for-styling/#fn2">CSS &#8211; Selecting Specific Elements for Styling</a>.<a href="#fnref4" class="footnote-back">↩</a></li>
<li id="fn5">Of course, if the browser window is narrower than 960px the page will overflow the browser window &#8211; the likely result being a horizontal scroll bar. In future tutorials, we will see how to dynamically adjust the page width and layout to fit different browser window widths. This is known as <strong>Responsive Web Design</strong><a href="#fnref5" class="footnote-back">↩</a></li>
<li id="fn6">Using percentage as a width value was discussed in <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2/#percentage-as-a-dimension"></a><a href="#fnref6" class="footnote-back">↩</a></li>
<li id="fn7">This is a common design style: start with the largest structures and nest things inside until we get to the individual elements. It may seem unnecessary, but it makes for easier maintainability. Remember, <span class="html-tag">div</span> has no semantic meaning, it only provides structure. See <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/sectioning-using-html-and-auto-centering-content/#div">Sectioning Using HTML and Auto Centering Content</a><a href="#fnref7" class="footnote-back">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-2/">CSS &#8211; A More Advanced Float Example: Part 2</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; A More Advanced Float Example: Part 1</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-1/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Tue, 08 Jan 2019 14:23:29 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3748</guid>

					<description><![CDATA[<p>Taking everything we've learned so far and using it to make a more sophisticated page layout using floats.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-1/">CSS &#8211; A More Advanced Float Example: Part 1</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
<p>Taking what we know about <span class="css-property">float</span> and creating a more sophisticated webpage layout.</p>
<p>Instead of creating our own layout, we will copy &#8211; more or less &#8211; an existing design.</p>
<p>It doesn’t have to be an exact copy.</p>
</div>
<h2>Contents</h2>
<ol class="incremental" type="1">
<li><a href="#the-objective">The Objective</a></li>
<li><a href="#simplifications">Simplifications</a></li>
<li><a href="#a-tease-of-what-it-could-look-like">A Tease of What It Could Look Like</a></li>
</ol>
<h2 id="the-objective">The Objective</h2>
<ol class="incremental" type="1">
<li>Copy &#8211; more or less &#8211; the layout of the homepage of the website <a href="https://engadget.com">Engadget</a> which can be done using <span class="css-property">float</span>.</li>
<li>Don’t clone the <em>whole</em> page, just the part that you see in your web browser without scrolling. In my browser window, Engadget looks something like this (I eliminated the ads from the page for simplicity):<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3749" src="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min.jpg" alt="A screenshot of a website home page." width="600" height="426" srcset="https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min.jpg 600w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/30-float-2-min-300x213.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" />It might look different in your browser.</li>
<li>Don’t make the webpage functional &#8211; just go for the look. Creating clickable article links, a working navigation menu, search and login functions are beyond the scope of this exercise. This exercise is just about layout.</li>
<li>Include a footer at the bottom.</li>
</ol>
<h2 id="simplifications">Simplifications</h2>
<p>To make things easier:</p>
<ol class="incremental" type="1">
<li>Assume the articles in the central column are the same size instead being a large item on top and two smaller items beneath.</li>
<li>Since the only fonts you know<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a> are <span class="css-value">serif</span>, <span class="css-value">sans-serif</span>, and <span class="css-value">monospace</span> don’t worry about trying to match the fonts.<a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a></li>
</ol>
<h2 id="a-tease-of-what-it-could-look-like">A Tease of What It Could Look Like</h2>
<p>Over the next two tutorials, I will develop code to create a page that looks like this:</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3750" src="https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-float-clone-min.jpg" alt="A screenshot of a website home page." width="600" height="591" srcset="https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-float-clone-min.jpg 600w, https://complete-concrete-concise.com/wp-content/uploads/2019/01/32-float-clone-min-300x296.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p>This page is similar, but not identical, to the Engadget homepage.</p>
<p>Depending on your browser display width, the Engadget homepage may appear differently. For displays 960 pixels or wider, it should look similar.</p>
<div class="prev">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-how-and-when-to-use-float/">Prev</a></p>
</div>
<div class="next">
<p><a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-2/">Next</a></p>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr>
<ol>
<li id="fn1">Fonts were covered in <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/nine-more-css-properties-to-play-with/#font-family">Nine More CSS Properties to Play With</a><a href="#fnref1" class="footnote-back">↩</a></li>
<li id="fn2">Future tutorials will cover how to specify other types of fonts, like: Times New Roman, Helvetica, Comic Sans, etc.<a href="#fnref2" class="footnote-back">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-more-advanced-float-example-part-1/">CSS &#8211; A More Advanced Float Example: Part 1</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; A Simple Page Using Float</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-simple-page-using-float/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Wed, 30 May 2018 06:58:32 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3729</guid>

					<description><![CDATA[<p>A simple example putting theoretical knowledge of floats into practice.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-simple-page-using-float/">CSS &#8211; A Simple Page Using Float</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
The previous <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2">exercise</a> asked to create a page with the following layout:</p>
<div style="width: 70%; background: yellow; text-align: center; height: 50px; margin: auto; padding-top: 16px;">Header section</div>
<div style="width: 70%; background: green; margin: auto;">
<div style="width: 80%; background: cyan; margin: auto; padding: 2em 0 2em 0; text-align: center;">Large image goes here.</div>
<div style="width: 80%; height: 50px; margin: auto; margin-top: 20px;">
<div style="width: 30%; height: 50px; margin: 1.66%; background: lime; text-align: center; float: left;">Smaller image</div>
<div style="width: 30%; height: 50px; margin: 1.66%; background: lime; text-align: center; float: left;">Smaller image</div>
<div style="width: 30%; height: 50px; margin: 1.66%; background: lime; text-align: center; float: left;">Smaller image</div>
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>
</div>
<div style="width: 70%; background: fuchsia; text-align: center; margin: auto;">Footer section</div>
<p>The purpose being to try and use floating elements in a design.
</p></div>
<h2>Contents</h2>
<ol type="1">
<li><a href="#an-example-using-float">An Example Using <span class="css-property">float</span></a></li>
<li><a href="#source-code">Source Code</a></li>
<li><a href="#notes">Notes</a></li>
<li><a href="#image-credits">Image Credits</a></li>
</ol>
<h2 id="an-example-using-float">An Example Using <span class="css-property">float</span></h2>
<p>You can see how the page I styled and structured using <span class="css-property">float</span> looks <a href="https://complete-concrete-concise.com/sample/28-float-example.html">here</a>.</p>
<h2 id="source-code">Source Code</h2>
<div id="cb1" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb1-1" class="sourceLine" data-line-number="1"></a><span class="dt">&lt;!DOCTYPE </span>HTML<span class="dt">&gt;</span>
<a id="cb1-2" class="sourceLine" data-line-number="2"></a><span class="kw">&lt;html&gt;</span>
<a id="cb1-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;head&gt;</span>
<a id="cb1-4" class="sourceLine" data-line-number="4"></a>    <span class="kw">&lt;title&gt;</span>Floating on Dreams<span class="kw">&lt;/title&gt;</span>
<a id="cb1-5" class="sourceLine" data-line-number="5"></a>    <span class="kw">&lt;meta</span><span class="ot"> charset=</span><span class="st">"utf-8"</span>  <span class="kw">/&gt;</span>
<a id="cb1-6" class="sourceLine" data-line-number="6"></a>
<a id="cb1-7" class="sourceLine" data-line-number="7"></a>    <span class="kw">&lt;style&gt;</span>
<a id="cb1-8" class="sourceLine" data-line-number="8"></a>
<a id="cb1-9" class="sourceLine" data-line-number="9"></a>      <span class="pp">#title</span> {
<a id="cb1-10" class="sourceLine" data-line-number="10"></a>        <span class="kw">font-size</span>: <span class="dv">48px</span>;
<a id="cb1-11" class="sourceLine" data-line-number="11"></a>        <span class="kw">text-align</span>: <span class="dv">center</span>;
<a id="cb1-12" class="sourceLine" data-line-number="12"></a>      }
<a id="cb1-13" class="sourceLine" data-line-number="13"></a>
<a id="cb1-14" class="sourceLine" data-line-number="14"></a>      <span class="pp">#subtitle</span> {
<a id="cb1-15" class="sourceLine" data-line-number="15"></a>        <span class="kw">font-size</span>: <span class="dv">24px</span>;
<a id="cb1-16" class="sourceLine" data-line-number="16"></a>        <span class="kw">text-align</span>: <span class="dv">center</span>;
<a id="cb1-17" class="sourceLine" data-line-number="17"></a>      }
<a id="cb1-18" class="sourceLine" data-line-number="18"></a>
<a id="cb1-19" class="sourceLine" data-line-number="19"></a>      <span class="fu">.main</span> {
<a id="cb1-20" class="sourceLine" data-line-number="20"></a>        <span class="kw">font-family</span>: <span class="dv">sans-serif</span>;
<a id="cb1-21" class="sourceLine" data-line-number="21"></a>        <span class="kw">box-sizing</span>: <span class="dv">border-box</span>;
<a id="cb1-22" class="sourceLine" data-line-number="22"></a>        <span class="kw">width</span>: <span class="dv">960px</span>;
<a id="cb1-23" class="sourceLine" data-line-number="23"></a>        <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb1-24" class="sourceLine" data-line-number="24"></a>      }
<a id="cb1-25" class="sourceLine" data-line-number="25"></a>
<a id="cb1-26" class="sourceLine" data-line-number="26"></a>      <span class="fu">.header</span> {
<a id="cb1-27" class="sourceLine" data-line-number="27"></a>
<a id="cb1-28" class="sourceLine" data-line-number="28"></a>      }
<a id="cb1-29" class="sourceLine" data-line-number="29"></a>
<a id="cb1-30" class="sourceLine" data-line-number="30"></a>      <span class="fu">.images</span> {
<a id="cb1-31" class="sourceLine" data-line-number="31"></a>      }
<a id="cb1-32" class="sourceLine" data-line-number="32"></a>
<a id="cb1-33" class="sourceLine" data-line-number="33"></a>      <span class="fu">.large-image</span> {
<a id="cb1-34" class="sourceLine" data-line-number="34"></a>          <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb1-35" class="sourceLine" data-line-number="35"></a>      }
<a id="cb1-36" class="sourceLine" data-line-number="36"></a>
<a id="cb1-37" class="sourceLine" data-line-number="37"></a>      <span class="fu">.small-image-container</span> {
<a id="cb1-38" class="sourceLine" data-line-number="38"></a>
<a id="cb1-39" class="sourceLine" data-line-number="39"></a>      }
<a id="cb1-40" class="sourceLine" data-line-number="40"></a>
<a id="cb1-41" class="sourceLine" data-line-number="41"></a>      <span class="fu">.small-image</span> {
<a id="cb1-42" class="sourceLine" data-line-number="42"></a>          <span class="kw">float</span>: <span class="dv">left</span>;
<a id="cb1-43" class="sourceLine" data-line-number="43"></a>          <span class="kw">margin</span>: <span class="dv">50px</span> <span class="dv">10px</span> <span class="dv">0</span> <span class="dv">10px</span>;
<a id="cb1-44" class="sourceLine" data-line-number="44"></a>      }
<a id="cb1-45" class="sourceLine" data-line-number="45"></a>
<a id="cb1-46" class="sourceLine" data-line-number="46"></a>      <span class="fu">.footer</span> {
<a id="cb1-47" class="sourceLine" data-line-number="47"></a>          <span class="kw">text-align</span>: <span class="dv">center</span>;
<a id="cb1-48" class="sourceLine" data-line-number="48"></a>      }
<a id="cb1-49" class="sourceLine" data-line-number="49"></a>
<a id="cb1-50" class="sourceLine" data-line-number="50"></a>      <span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb1-51" class="sourceLine" data-line-number="51"></a>        <span class="kw">clear</span>: <span class="dv">both</span>;
<a id="cb1-52" class="sourceLine" data-line-number="52"></a>        <span class="kw">display</span>: <span class="dv">block</span>;
<a id="cb1-53" class="sourceLine" data-line-number="53"></a>        <span class="kw">content</span>: <span class="st">""</span>;
<a id="cb1-54" class="sourceLine" data-line-number="54"></a>      }
<a id="cb1-55" class="sourceLine" data-line-number="55"></a>
<a id="cb1-56" class="sourceLine" data-line-number="56"></a>    <span class="kw">&lt;/style&gt;</span>
<a id="cb1-57" class="sourceLine" data-line-number="57"></a>
<a id="cb1-58" class="sourceLine" data-line-number="58"></a>  <span class="kw">&lt;/head&gt;</span>
<a id="cb1-59" class="sourceLine" data-line-number="59"></a>  <span class="kw">&lt;body&gt;</span>
<a id="cb1-60" class="sourceLine" data-line-number="60"></a>
<a id="cb1-61" class="sourceLine" data-line-number="61"></a>    <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"main"</span><span class="kw">&gt;</span>
<a id="cb1-62" class="sourceLine" data-line-number="62"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"header"</span><span class="kw">&gt;</span>
<a id="cb1-63" class="sourceLine" data-line-number="63"></a>        <span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">"title"</span><span class="kw">&gt;</span>Floating on Dreams<span class="kw">&lt;/p&gt;</span>
<a id="cb1-64" class="sourceLine" data-line-number="64"></a>        <span class="kw">&lt;p</span><span class="ot"> id=</span><span class="st">"subtitle"</span><span class="kw">&gt;</span>A simple page using floats<span class="kw">&lt;/p&gt;</span>
<a id="cb1-65" class="sourceLine" data-line-number="65"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-66" class="sourceLine" data-line-number="66"></a>
<a id="cb1-67" class="sourceLine" data-line-number="67"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"images"</span><span class="kw">&gt;</span>
<a id="cb1-68" class="sourceLine" data-line-number="68"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"large-image"</span><span class="kw">&gt;</span>
<a id="cb1-69" class="sourceLine" data-line-number="69"></a>          <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"28-big-image.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-70" class="sourceLine" data-line-number="70"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb1-71" class="sourceLine" data-line-number="71"></a>
<a id="cb1-72" class="sourceLine" data-line-number="72"></a>        <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"small-image-container clearfix"</span><span class="kw">&gt;</span>
<a id="cb1-73" class="sourceLine" data-line-number="73"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"small-image"</span><span class="kw">&gt;</span>
<a id="cb1-74" class="sourceLine" data-line-number="74"></a>            <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"28-small-1.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-75" class="sourceLine" data-line-number="75"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-76" class="sourceLine" data-line-number="76"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"small-image"</span><span class="kw">&gt;</span>
<a id="cb1-77" class="sourceLine" data-line-number="77"></a>            <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"28-small-2.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-78" class="sourceLine" data-line-number="78"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-79" class="sourceLine" data-line-number="79"></a>          <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"small-image"</span><span class="kw">&gt;</span>
<a id="cb1-80" class="sourceLine" data-line-number="80"></a>            <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">"28-small-3.jpg"</span><span class="kw">&gt;</span>
<a id="cb1-81" class="sourceLine" data-line-number="81"></a>          <span class="kw">&lt;/div&gt;</span>
<a id="cb1-82" class="sourceLine" data-line-number="82"></a>        <span class="kw">&lt;/div&gt;</span>
<a id="cb1-83" class="sourceLine" data-line-number="83"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-84" class="sourceLine" data-line-number="84"></a>
<a id="cb1-85" class="sourceLine" data-line-number="85"></a>      <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"footer"</span><span class="kw">&gt;</span>
<a id="cb1-86" class="sourceLine" data-line-number="86"></a>        <span class="kw">&lt;p&gt;</span>Copyright 2018<span class="kw">&lt;/p&gt;</span>
<a id="cb1-87" class="sourceLine" data-line-number="87"></a>      <span class="kw">&lt;/div&gt;</span>
<a id="cb1-88" class="sourceLine" data-line-number="88"></a>
<a id="cb1-89" class="sourceLine" data-line-number="89"></a>    <span class="kw">&lt;/div&gt;</span>
<a id="cb1-90" class="sourceLine" data-line-number="90"></a>
<a id="cb1-91" class="sourceLine" data-line-number="91"></a>  <span class="kw">&lt;/body&gt;</span>
<a id="cb1-92" class="sourceLine" data-line-number="92"></a><span class="kw">&lt;/html&gt;</span></code></pre>
</div>
<h2 id="notes">Notes</h2>
<ol type="1">
<li>The first thing that needs to be done is to divide the document into nesting and stacking HTML blocks.</li>
<li>This is one possible way to section the document: <a href="https://complete-concrete-concise.com/wp-content/uploads/2018/05/28-float.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3731" src="https://complete-concrete-concise.com/wp-content/uploads/2018/05/28-float.png" alt="" width="600" height="800" /></a></li>
<li>There is always a <strong>Main</strong> container which contains all the content. It was set to have a width of 960 pixels.</li>
<li>The <strong>Header</strong> and <strong>Footer</strong> blocks are nested inside the <strong>main</strong> container.</li>
<li>Between the <strong>header</strong> and <strong>footer</strong> there is some content. The content (in this case) is images and is contained within an <strong>Images</strong> container.</li>
<li>Nested inside the <strong>images</strong> container is a stacking of large and small images.</li>
<li>The large image has its own container</li>
<li>The small floating images are wrapped in their own container so they act like a single block. The small images block has <span class="css-class">.clearfix</span> applied to it.</li>
<li>Not all the sectioning <span class="html-tag">div</span>s have styling applied since their sole purpose is to provide structure.</li>
<li>While styling could have been applied directly to the <span class="html-tag">img</span> tags, I chose to wrap them in a <span class="html-tag">div</span> because it allows for greater flexibility in the future.
<ul>
<li>Imagine turning those small floating images into a “card”:
<div style="border: 2px solid black; width: 320px; background: gold;">
<img decoding="async" style="margin: 10px 0 0 10px;" src="https://complete-concrete-concise.com/sample/28-small-3.jpg" /></p>
<p style="font-size: 24px; text-align: center;">A Pensive Cat</p>
</div>
</li>
</ul>
</li>
</ol>
<h2 id="image-credits">Image Credits</h2>
<p>The images I used are courtesy of:</p>
<ol type="1">
<li><a href="https://pixabay.com/en/natural-landscape-azores-nature-1758541/">charloisporto</a> : Tranquil nature scene</li>
<li><a href="https://pixabay.com/en/fruit-fruits-fruit-salad-frisch-2305192/">silviarita</a> : Fruit salad</li>
<li><a href="https://pixabay.com/en/relaxation-yoga-the-concentration-of-1967892/">Ataner007</a> : Woman meditating</li>
<li><a href="https://pixabay.com/en/cat-young-animal-curious-wildcat-2083492/">susannp4</a> : Cat</li>
</ol>
<div class="prev">
<a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2">Prev</a>
</div>
<div class="next">
<a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-how-and-when-to-use-float">Next</a>
</div>
<div class="clear"></div>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-simple-page-using-float/">CSS &#8211; A Simple Page Using Float</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; Understanding How Float Works &#8211; Part 2</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Thu, 24 May 2018 15:44:45 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3709</guid>

					<description><![CDATA[<p>Delving deeper into how floating elements position themselves side-to-side instead of top-to-bottom.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2/">CSS &#8211; Understanding How Float Works &#8211; Part 2</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
We’ve seen that the <span class="css-property">float</span> can be used to place an HTML to the side of other content.<br />
How does it do this and why does it seem to overlap other HTML elements?
</div>
<h2>Contents</h2>
<ol type="1">
<li><a href="#floated-elements-flow-sideways">Floated Elements Flow Sideways</a></li>
<li><a href="#floating-elements-wrap-if-there-is-not-enough-space">Floating Elements Wrap If There Is Not Enough Space</a></li>
<li><a href="#wrapping-is-dependent-on-which-way-the-element-floats">Wrapping is Dependent on Which Way the Element Floats</a></li>
<li><a href="#percentage-as-a-dimension">Percentage as a Dimension</a></li>
<li><a href="#marginauto-has-no-effect-on-floats"><span class="css-property">margin:auto</span> Has No Effect on Floats</a></li>
<li><a href="#expanding-a-floating-child-to-fit-its-parent">Expanding a Floating Child to Fit Its Parent</a></li>
<li><a href="#summary">Summary</a></li>
<li><a href="#playing-around">Playing Around</a></li>
<li><a href="#references">References</a></li>
</ol>
<h2 id="floated-elements-flow-sideways">Floated Elements Flow Sideways</h2>
<p>HTML elements flow from top to bottom in the order in which they appear in the HTML document. This is called <strong>normal flow</strong>.<br />
Floating elements are outside of <strong>normal flow</strong> and do not stack top to bottom. Instead, they stack from <em>left-to-right</em> for <span class="css-value">left</span> floated elements and <em>right-to-left</em> for <span class="css-value">right</span> floated elements.<br />
Consider the following code:<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a></p>
<div id="cb1" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb1-1" class="sourceLine" data-line-number="1"></a><span class="fu">.box</span> {
<a id="cb1-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">width</span>: <span class="dv">50px</span>;
<a id="cb1-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">height</span>: <span class="dv">50px</span>;
<a id="cb1-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">border</span>: <span class="dv">1px</span> <span class="dv">solid</span> <span class="dv">black</span>;
<a id="cb1-5" class="sourceLine" data-line-number="5"></a>}
<a id="cb1-6" class="sourceLine" data-line-number="6"></a>
<a id="cb1-7" class="sourceLine" data-line-number="7"></a><span class="fu">.left</span> {
<a id="cb1-8" class="sourceLine" data-line-number="8"></a>  <span class="kw">float</span>: <span class="dv">left</span>;
<a id="cb1-9" class="sourceLine" data-line-number="9"></a>}
<a id="cb1-10" class="sourceLine" data-line-number="10"></a>
<a id="cb1-11" class="sourceLine" data-line-number="11"></a><span class="fu">.right</span> {
<a id="cb1-12" class="sourceLine" data-line-number="12"></a>  <span class="kw">float</span>: <span class="dv">right</span>;
<a id="cb1-13" class="sourceLine" data-line-number="13"></a>}
<a id="cb1-14" class="sourceLine" data-line-number="14"></a>
<a id="cb1-15" class="sourceLine" data-line-number="15"></a><span class="fu">.centre</span> {
<a id="cb1-16" class="sourceLine" data-line-number="16"></a>  <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb1-17" class="sourceLine" data-line-number="17"></a>}
<a id="cb1-18" class="sourceLine" data-line-number="18"></a>
<a id="cb1-19" class="sourceLine" data-line-number="19"></a><span class="fu">.yellow</span> {
<a id="cb1-20" class="sourceLine" data-line-number="20"></a>  <span class="kw">background-color</span>: <span class="dv">yellow</span>;
<a id="cb1-21" class="sourceLine" data-line-number="21"></a>}
<a id="cb1-22" class="sourceLine" data-line-number="22"></a>
<a id="cb1-23" class="sourceLine" data-line-number="23"></a><span class="fu">.lime</span> {
<a id="cb1-24" class="sourceLine" data-line-number="24"></a>  <span class="kw">background-color</span>: <span class="dv">lime</span>;
<a id="cb1-25" class="sourceLine" data-line-number="25"></a>}
<a id="cb1-26" class="sourceLine" data-line-number="26"></a>
<a id="cb1-27" class="sourceLine" data-line-number="27"></a><span class="fu">.orange</span> {
<a id="cb1-28" class="sourceLine" data-line-number="28"></a>  <span class="kw">background-color</span>: orange;
<a id="cb1-29" class="sourceLine" data-line-number="29"></a>}
<a id="cb1-30" class="sourceLine" data-line-number="30"></a>
<a id="cb1-31" class="sourceLine" data-line-number="31"></a><span class="fu">.cyan</span> {
<a id="cb1-32" class="sourceLine" data-line-number="32"></a>  <span class="kw">background-color</span>: <span class="dv">cyan</span>;
<a id="cb1-33" class="sourceLine" data-line-number="33"></a>}</code></pre>
</div>
<div id="cb2" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb2-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box yellow left"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-2" class="sourceLine" data-line-number="2"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box lime left"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-3" class="sourceLine" data-line-number="3"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box orange left"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-4" class="sourceLine" data-line-number="4"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box cyan left"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-5" class="sourceLine" data-line-number="5"></a>
<a id="cb2-6" class="sourceLine" data-line-number="6"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box yellow right"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-7" class="sourceLine" data-line-number="7"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box lime right"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-8" class="sourceLine" data-line-number="8"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box orange right"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-9" class="sourceLine" data-line-number="9"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box cyan right"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-10" class="sourceLine" data-line-number="10"></a>
<a id="cb2-11" class="sourceLine" data-line-number="11"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box yellow centre"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-12" class="sourceLine" data-line-number="12"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box lime centre"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-13" class="sourceLine" data-line-number="13"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box orange centre"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-14" class="sourceLine" data-line-number="14"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box cyan centre"</span><span class="kw">&gt;&lt;/div&gt;</span></code></pre>
</div>
<p>Which gives the following output:</p>
<div class="html-output">
<style>.box {width: 50px; height: 50px; border: 1px solid black;} .left {  float: left;} .right {  float: right;} .centre {  margin: auto;} .yellow {  background-color: yellow;} .lime {  background-color: lime;} .orange {  background-color: orange;} .cyan {  background-color: cyan;}</style>
<div class="box yellow left"></div>
<div class="box lime left"></div>
<div class="box orange left"></div>
<div class="box cyan left"></div>
<div class="box yellow right"></div>
<div class="box lime right"></div>
<div class="box orange right"></div>
<div class="box cyan right"></div>
<div class="box yellow centre"></div>
<div class="box lime centre"></div>
<div class="box orange centre"></div>
<div class="box cyan centre"></div>
</div>
<p>You will notice that:</p>
<ol type="1">
<li>3 sets of coloured boxes are declared in the same order (<span class="css-class">.yellow</span>, <span class="css-class">.lime</span>, <span class="css-class">.orange</span>, and <span class="css-class">.cyan</span>)</li>
<li>each set of boxes is given a different alignment class (<span class="css-class">.left</span>, <span class="css-class">.right</span>, or <span class="css-class">.centre</span>)</li>
<li>the boxes on the left stack from <strong>left-to-right</strong> in the same order they were declared</li>
<li>the boxes on the right stack from <strong>right-to-left</strong> in the same order they were declared</li>
<li>the boxes in the middle stack from <strong>top to bottom</strong> in the same order they were declared</li>
<li>because the <span class="css-class">.left</span> boxes and <span class="css-class">.right</span> boxes are not in <strong>normal flow</strong>, the <span class="css-class">.centre</span> stacked boxes occupy their place in the <strong>normal flow</strong>.</li>
</ol>
<p>Recall that (relative to their parent):</p>
<ol type="1">
<li>floating elements float up as high as they can. They stop when they either encounter the top margin of their parent or the bottom margin of a non-floating element.</li>
<li>floating elements float as far to the side as they can. They stop when they either encounter the side margin of their parent or the side margin of another floating element.</li>
</ol>
<p>This is exactly what we observe in the example above:</p>
<ol type="1">
<li>the floated elements are declared at the top of the document, so they float up to the margin of the parent &#8211; they are not stopped by the bottom margin of other floating elements</li>
<li>the floated elements flow as far to the side as they can and are stopped either by the side margin of the parent (the yellow block) or the side margin of another floating element (the other blocks).</li>
</ol>
<h2 id="floating-elements-wrap-if-there-is-not-enough-space">Floating Elements Wrap If There Is Not Enough Space</h2>
<p>Elements in <strong>normal flow</strong> stack one atop the other and continue down the bottom of the page as far as needed.<br />
Floated elements do not stack sideways as far as they can go &#8211; they are constrained by the width of their parent (assuming you don’t make the child wider than its parent). Any floating elements for which there is not enough room to stack sideways will flow to the next line.<br />
Consider the following 4 <span class="css-value">left</span> floating blocks (they are scaled to each take up 25% of the available width):</p>
<div class="html-output">
<div style="width: 25%; height: 50px; background: yellow; float: left;"></div>
<div style="width: 25%; height: 50px; background: lime; float: left;"></div>
<div style="width: 25%; height: 50px; background: orange; float: left;"></div>
<div style="width: 25%; height: 50px; background: cyan; float: left;"></div>
<div style="clear: both;"></div>
</div>
<p>They all line up in a single line as expected.<br />
If we make them a little wider, say 26% of the width of the parent container:</p>
<div class="html-output">
<div style="width: 26%; height: 50px; background: yellow; float: left;"></div>
<div style="width: 26%; height: 50px; background: lime; float: left;"></div>
<div style="width: 26%; height: 50px; background: orange; float: left;"></div>
<div style="width: 26%; height: 50px; background: cyan; float: left;"></div>
<div style="clear: both;"></div>
</div>
<p>We see that the blue block, because it doesn’t fit, automatically wraps to the next line and moves as far left as it can.<br />
A similar thing happens for <span class="css-value">right</span> floated elements &#8211; except everything moves as far right as it can:</p>
<div class="html-output">
<div style="width: 26%; height: 50px; background: yellow; float: right;"></div>
<div style="width: 26%; height: 50px; background: lime; float: right;"></div>
<div style="width: 26%; height: 50px; background: orange; float: right;"></div>
<div style="width: 26%; height: 50px; background: cyan; float: right;"></div>
<div style="clear: both;"></div>
</div>
<h2 id="wrapping-is-dependent-on-which-way-the-element-floats">Wrapping is Dependent on Which Way the Element Floats</h2>
<p>Sometimes, you can get some unexpected float behaviour if you don’t remember that floating elements:</p>
<ol type="1">
<li>float up as high as they can</li>
<li>then float to the side</li>
<li>in the order they are declared in the document.</li>
</ol>
<p>Consider the following:</p>
<div id="cb3" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb3-1" class="sourceLine" data-line-number="1"></a><span class="fu">.parent</span> {
<a id="cb3-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">width</span>: <span class="dv">400px</span>;
<a id="cb3-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">background-color</span>: <span class="dv">red</span>;
<a id="cb3-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb3-5" class="sourceLine" data-line-number="5"></a>}
<a id="cb3-6" class="sourceLine" data-line-number="6"></a>
<a id="cb3-7" class="sourceLine" data-line-number="7"></a><span class="fu">.left-box</span> {
<a id="cb3-8" class="sourceLine" data-line-number="8"></a>  <span class="kw">width</span>: <span class="dv">250px</span>;
<a id="cb3-9" class="sourceLine" data-line-number="9"></a>  <span class="kw">height</span>: <span class="dv">100px</span>;
<a id="cb3-10" class="sourceLine" data-line-number="10"></a>  <span class="kw">background-color</span>: <span class="dv">yellow</span>;
<a id="cb3-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">float</span>: <span class="dv">left</span>;
<a id="cb3-12" class="sourceLine" data-line-number="12"></a>}
<a id="cb3-13" class="sourceLine" data-line-number="13"></a>
<a id="cb3-14" class="sourceLine" data-line-number="14"></a><span class="fu">.right-box</span> {
<a id="cb3-15" class="sourceLine" data-line-number="15"></a>  <span class="kw">width</span>: <span class="dv">250px</span>;
<a id="cb3-16" class="sourceLine" data-line-number="16"></a>  <span class="kw">height</span>: <span class="dv">100px</span>;
<a id="cb3-17" class="sourceLine" data-line-number="17"></a>  <span class="kw">background-color</span>: <span class="dv">lime</span>;
<a id="cb3-18" class="sourceLine" data-line-number="18"></a>  <span class="kw">float</span>: <span class="dv">right</span>;
<a id="cb3-19" class="sourceLine" data-line-number="19"></a>}</code></pre>
</div>
<div id="cb4" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb4-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"parent"</span><span class="kw">&gt;</span>
<a id="cb4-2" class="sourceLine" data-line-number="2"></a>  Parent Box
<a id="cb4-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"right-box"</span><span class="kw">&gt;</span>Right Box<span class="kw">&lt;/div&gt;</span>
<a id="cb4-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"left-box"</span><span class="kw">&gt;</span>Left Box<span class="kw">&lt;/div&gt;</span>
<a id="cb4-5" class="sourceLine" data-line-number="5"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<div class="html-output">
<div style="width: 400px; background-color: red; margin: auto;">
Parent Box</p>
<div style="width: 250px; height: 100px; background-color: lime; float: right;">Right Box</div>
<div style="width: 250px; height: 100px; background-color: yellow; float: left;">Left Box</div>
<div style="clear: both;"></div>
</div>
</div>
<p>The sum of both floats is wider than the parent, so:</p>
<ol type="1">
<li>the floats can’t both fit on the same line (250px + 250px is greater than the 400px of the parent)</li>
<li>the floats wrap</li>
<li>they wrap in the order they were declared in the document (the <span class="css-value">right</span> element is placed first, then the <span class="css-value">left</span>).</li>
</ol>
<p>Of course, you can have elements float to the left and right on the same line. If we change the <span class="css-property">width</span> of the floats in the above example to <span class="css-value">100px</span>, we get:</p>
<div class="html-output">
<div style="width: 400px; background-color: red; margin: auto;">
Parent Box</p>
<div style="width: 100px; height: 100px; background-color: lime; float: right;">Right Box</div>
<div style="width: 100px; height: 100px; background-color: yellow; float: left;">Left Box</div>
<div style="clear: both;"></div>
</div>
</div>
<p>Remember that parts of the parent CSS Box is under both the left and right boxes, but the content in the parent box is never under a floating element.</p>
<h2 id="percentage-as-a-dimension">Percentage as a Dimension</h2>
<p>Up till now, we have always used pixels as a dimensioning unit. CSS has many ways of dimensioning things. It can be easier to work with float widths as a percentage of the parent container width. When using <strong>%</strong> as a dimension, it refers to the width of the container as a percentage of the parent width.<br />
Consider the following:</p>
<div id="cb5" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb5-1" class="sourceLine" data-line-number="1"></a><span class="fu">.box</span> {
<a id="cb5-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb5-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">height</span>: <span class="dv">50px</span>;
<a id="cb5-4" class="sourceLine" data-line-number="4"></a>}
<a id="cb5-5" class="sourceLine" data-line-number="5"></a>
<a id="cb5-6" class="sourceLine" data-line-number="6"></a><span class="fu">.w30</span> {
<a id="cb5-7" class="sourceLine" data-line-number="7"></a>  <span class="kw">width</span>: <span class="dv">30%</span>;
<a id="cb5-8" class="sourceLine" data-line-number="8"></a>  <span class="kw">background-color</span>: <span class="dv">yellow</span>;
<a id="cb5-9" class="sourceLine" data-line-number="9"></a>}
<a id="cb5-10" class="sourceLine" data-line-number="10"></a>
<a id="cb5-11" class="sourceLine" data-line-number="11"></a><span class="fu">.w50</span> {
<a id="cb5-12" class="sourceLine" data-line-number="12"></a>  <span class="kw">width</span>: <span class="dv">50%</span>;
<a id="cb5-13" class="sourceLine" data-line-number="13"></a>  <span class="kw">background-color</span>: <span class="dv">lime</span>;
<a id="cb5-14" class="sourceLine" data-line-number="14"></a>}</code></pre>
</div>
<div id="cb6" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb6-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box w30"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb6-2" class="sourceLine" data-line-number="2"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box w50"</span><span class="kw">&gt;&lt;/div&gt;</span></code></pre>
</div>
<div class="html-output">
<style> .xbox {  margin: auto;  height: 50px;} .w30 {  width: 30%;  background-color: yellow;} .w50 {  width: 50%;  background-color: lime;}</style>
<div class="xbox w30"></div>
<div class="xbox w50"></div>
</div>
<p>The yellow box is 30% of the width of its parent.<br />
The green box is 50% of the width of its parent.<br />
If the width of the parent changes, the widths of the child elements will adjust automatically. This can be useful if you want your web content to adapt its size to the browser window width.<br />
It is also useful if you want to quickly divide up the available real estate. Consider the following:</p>
<div id="cb7" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb7-1" class="sourceLine" data-line-number="1"></a><span class="fu">.parent</span> {
<a id="cb7-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">width</span>: <span class="dv">400px</span>;
<a id="cb7-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">height</span>: <span class="dv">200px</span>;
<a id="cb7-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb7-5" class="sourceLine" data-line-number="5"></a>}
<a id="cb7-6" class="sourceLine" data-line-number="6"></a>
<a id="cb7-7" class="sourceLine" data-line-number="7"></a><span class="fu">.main</span> {
<a id="cb7-8" class="sourceLine" data-line-number="8"></a>  <span class="kw">width</span>: <span class="dv">70%</span>;
<a id="cb7-9" class="sourceLine" data-line-number="9"></a>  <span class="kw">height</span>: <span class="dv">100%</span>;
<a id="cb7-10" class="sourceLine" data-line-number="10"></a>  <span class="kw">background-color</span>: <span class="dv">lime</span>;
<a id="cb7-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">float</span>: <span class="dv">left</span>;
<a id="cb7-12" class="sourceLine" data-line-number="12"></a>}
<a id="cb7-13" class="sourceLine" data-line-number="13"></a>
<a id="cb7-14" class="sourceLine" data-line-number="14"></a><span class="fu">.sidebar</span> {
<a id="cb7-15" class="sourceLine" data-line-number="15"></a>  <span class="kw">width</span>: <span class="dv">30%</span>;
<a id="cb7-16" class="sourceLine" data-line-number="16"></a>  <span class="kw">height</span>: <span class="dv">100%</span>;
<a id="cb7-17" class="sourceLine" data-line-number="17"></a>  <span class="kw">background-color</span>: <span class="dv">cyan</span>;
<a id="cb7-18" class="sourceLine" data-line-number="18"></a>  <span class="kw">float</span>:<span class="dv">left</span>;
<a id="cb7-19" class="sourceLine" data-line-number="19"></a>}</code></pre>
</div>
<div id="cb8" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb8-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"parent"</span><span class="kw">&gt;</span>
<a id="cb8-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"main"</span><span class="kw">&gt;</span>
<a id="cb8-3" class="sourceLine" data-line-number="3"></a>    Main content goes here.
<a id="cb8-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb8-5" class="sourceLine" data-line-number="5"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"sidebar"</span><span class="kw">&gt;</span>
<a id="cb8-6" class="sourceLine" data-line-number="6"></a>    Sidebar content goes here.
<a id="cb8-7" class="sourceLine" data-line-number="7"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb8-8" class="sourceLine" data-line-number="8"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<div class="html-output">
<div style="width: 400px; height: 200px; margin: auto;">
<div style="width: 70%; height: 100%; background-color: lime; float: left;">
Main content goes here.
</div>
<div style="width: 30%; height: 100%; background-color: cyan; float: left;">
Sidebar content goes here.
</div>
<div style="clear: both;"></div>
</div>
</div>
<p>Each floating box gets the specified percentage of the parent’s area. The parent size can be easily changed without having to update the individual sizes of the floating elements.</p>
<h2 id="expanding-a-floating-child-to-fit-its-parent">Expanding a Floating Child to Fit Its Parent</h2>
<p>A floating child element will <strong>only</strong> fill out the parent’s height only if the parent has a definite height specified (e.g. 200px). If no height is specified for the parent or a percentage height is specified for the parent, the floating child will not expand to fill the height of the parent &#8211; even if <span class="css-class">.clearfix</span> is used to expand the parent around the floating children.<br />
Using the same code as above, but</p>
<ol type="1">
<li>setting the parent <span class="css-property">height</span> to <span class="css-value">100%</span>,</li>
<li>setting its <span class="css-property">background-color</span> to yellow, and</li>
<li>clearing the floats after the last float (so the parent expands around the floating children):</li>
</ol>
<div class="html-output">
<div style="width: 400px; height: 100%; margin: auto; background: yellow;">
<div style="width: 70%; height: 100%; background-color: lime; float: left; vertical-align: bottom; display: table-cell;">
Main content goes here.
</div>
<div style="width: 30%; height: 100%; background-color: cyan; float: left;">
Sidebar content goes here.
</div>
<div style="clear: both;"></div>
</div>
</div>
<p>We see that the parent (yellow) has closed around its children. It has expanded to the height of the sidebar box, but the main content box (despite having its <span class="css-property">height</span> set to <span class="css-value">100%</span>) has not expanded to the bottom of the parent.<br />
If the parent does not have a fixed height, it is not possible to make a floating child expand to the height of its parent without either:</p>
<ul>
<li>using JavaScript,<a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a> or</li>
<li>using a different positioning technique.<a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a></li>
</ul>
<p>The only time this (usually) becomes an issue is when children and parents have different background colours, borders, or other properties that makes it obvious the floating child and parent are not the same height.<br />
Floating children will always respect the <span class="css-property">width</span> of the parent &#8211; as long as you do not make the child wider than the parent.</p>
<h2 id="marginauto-has-no-effect-on-floats"><span class="css-property">margin:auto</span> Has No Effect on Floats</h2>
<p>Setting <span class="css-property">margin</span> to <span class="css-value">auto</span><a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a> on a floating element will have no effect. This is because floating elements automatically float as far as they can to the left or right.<br />
However, you can set a fixed margin on a floating element and it will respect it:</p>
<div id="cb9" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb9-1" class="sourceLine" data-line-number="1"></a><span class="fu">.floating-box</span> {
<a id="cb9-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">width</span>:<span class="dv">150px</span>;
<a id="cb9-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">height</span>:<span class="dv">50px</span>;
<a id="cb9-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">float</span>: <span class="dv">left</span>;
<a id="cb9-5" class="sourceLine" data-line-number="5"></a>  <span class="kw">background-color</span>: <span class="dv">cyan</span>;
<a id="cb9-6" class="sourceLine" data-line-number="6"></a>  <span class="kw">margin-left</span>: <span class="dv">50px</span>;
<a id="cb9-7" class="sourceLine" data-line-number="7"></a>  <span class="kw">margin-top</span>: <span class="dv">50px</span>;
<a id="cb9-8" class="sourceLine" data-line-number="8"></a>}
<a id="cb9-9" class="sourceLine" data-line-number="9"></a>
<a id="cb9-10" class="sourceLine" data-line-number="10"></a><span class="fu">.parent-box</span> {
<a id="cb9-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">width</span>: <span class="dv">250px</span>;
<a id="cb9-12" class="sourceLine" data-line-number="12"></a>  <span class="kw">height</span>: <span class="dv">150px</span>;
<a id="cb9-13" class="sourceLine" data-line-number="13"></a>  <span class="kw">background-color</span>: <span class="dv">yellow</span>;
<a id="cb9-14" class="sourceLine" data-line-number="14"></a>  <span class="kw">margin</span>:<span class="dv">auto</span>;
<a id="cb9-15" class="sourceLine" data-line-number="15"></a>}</code></pre>
</div>
<div id="cb10" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb10-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"parent-box"</span><span class="kw">&gt;</span>
<a id="cb10-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floating-box"</span><span class="kw">&gt;</span>
<a id="cb10-3" class="sourceLine" data-line-number="3"></a>    This box is floating with margins.
<a id="cb10-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">&lt;/div&gt;</span>
<a id="cb10-5" class="sourceLine" data-line-number="5"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<div class="html-output">
<div style="width: 250px; height: 150px; background-color: yellow; margin: auto;">
<div style="width: 150px; height: 50px; float: left; background-color: cyan; margin-left: 50px; margin-top: 50px;">This box is floating with margins.</div>
</div>
</div>
<h2 id="summary">Summary</h2>
<ol type="1">
<li>Floating elements do not stack top to bottom.</li>
<li><span class="css-value">left</span> floated elements stack from left-to-right.</li>
<li><span class="css-value">right</span> floated elements stack from right-to-left.</li>
<li>Floating elements stack in the order they appear in the document.</li>
<li>If there is not enough room on a line to fit a floating element, the element moves down (wraps) to the next line and moves as far to the side as it can.</li>
<li>Instead of pixels, dimensions can be given as a percentage. The percentage is relative to the dimensions of the parent.</li>
<li>A floating child can be made to fit the full height of its parent by setting its <span class="css-property">height</span> to <span class="css-value">100%</span>. This only works if the parent has a defined height in pixels.</li>
<li><span class="css-property">margin:auto</span>, which is commonly used to centre HTML elements, is ignored when applied to floating elements.</li>
<li>Floating elements respect non-auto margin values.</li>
</ol>
<h2 id="playing-around">Playing Around</h2>
<p>The best way to learn is to play around with what you have learned.<br />
You have previously seen that you can use the <span class="html-tag">div</span> tag to section content in a document. Prior to seeing the <span class="css-property">float</span> property, the only possible flow of content was vertical &#8211; from top to bottom. With <span class="css-property">float</span> it is possible to get content to flow side-to-side.<br />
How would you section and style the following page layout using <span class="html-tag">div</span> and <span class="css-property">float</span>?</p>
<div>
<div style="width: 70%; background: yellow; text-align: center; height: 50px; margin: auto; padding-top: 16px;">Header section</div>
<div style="width: 70%; background: green; margin: auto;">
<div style="width: 80%; background: cyan; margin: auto; padding: 2em 0 2em 0; text-align: center;">Large image goes here.</div>
<div style="width: 80%; height: 50px; margin: auto; margin-top: 20px;">
<div style="width: 30%; height: 50px; margin: 1.66%; background: lime; text-align: center; float: left;">Smaller image</div>
<div style="width: 30%; height: 50px; margin: 1.66%; background: lime; text-align: center; float: left;">Smaller image</div>
<div style="width: 30%; height: 50px; margin: 1.66%; background: lime; text-align: center; float: left;">Smaller image</div>
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>
</div>
<div style="width: 70%; background: fuchsia; text-align: center; margin: auto;">Footer section</div>
</div>
<ol type="1">
<li>Make it look good in your browser on your computer. Don’t try to make it look good at all possible screen resolutions.</li>
<li>Think about how to section the document. Remember that <span class="html-tag">div</span>s can nest inside other <span class="html-tag">div</span>s.</li>
<li>The layout above is a rough template to give you direction on how to layout your document.</li>
<li>A general rule of thumb in web design is to make your layout 960px wide (which is then centred in the browser)<a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a>.</li>
</ol>
<h2 id="references">References</h2>
<ol type="1">
<li><a href="https://www.w3.org/TR/CSS2/visuren.html#propdef-float">float</a></li>
<li><a href="https://www.w3.org/TR/CSS2/visuren.html#flow-control">clear</a></li>
<li><a href="https://960.gs/demo.html">960 Grid</a></li>
</ol>
<div class="prev">
<a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-1">Prev</a>
</div>
<div class="next">
<a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-a-simple-page-using-float">Next</a>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">Feel free to use larger boxes, but in the article, I am somewhat constrained for space.<a class="footnote-back" href="#fnref1">↩</a></li>
<li id="fn2">Which will be covered in a future tutorial.<a class="footnote-back" href="#fnref2">↩</a></li>
<li id="fn3">CSS is incredibly flexible and there are lots of choices for positioning elements, but those are for future tutorials.<a class="footnote-back" href="#fnref3">↩</a></li>
<li id="fn4">Remember that <span class="css-value">auto</span> is how we get elements to centre inside a container. Effectively, we are asking the User Agent (browser) to apply equal margins to the left and right side.<a class="footnote-back" href="#fnref4">↩</a></li>
<li id="fn5">This tends to work fine for desktop browsers, but not so well for mobile browsers. Nevertheless, it is a good rule of thumb for dividing up and laying out content on your page.<a class="footnote-back" href="#fnref5">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2/">CSS &#8211; Understanding How Float Works &#8211; Part 2</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CSS &#8211; Understanding How Float Works &#8211; Part 1</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-1/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Fri, 11 May 2018 13:42:34 +0000</pubDate>
				<category><![CDATA[Front-End Basics]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3689</guid>

					<description><![CDATA[<p>The behaviour of floats can be mysterious (or frustrating). This tutorial helps take away some of the mystery (and pain) of dealing with floats.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-1/">CSS &#8211; Understanding How Float Works &#8211; Part 1</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
We’ve seen that the <span class="css-property">float</span> can be used to place an HTML element to the side of other content.<br />
How does it do this and why does it seem to overlap other HTML elements?
</div>
<h2>Contents</h2>
<ol type="1">
<li><a href="#a-quick-review-of-normal-flow">A Quick Review of Normal Flow</a></li>
<li><a href="#float-takes-the-element-out-of-normal-flow"><span class="css-property">float</span> Takes the Element Out of Normal Flow</a></li>
<li><a href="#float-changes-the-elements-display-property"><span class="css-property">float</span> Changes the Element’s <span class="css-property">display</span> Property</a></li>
<li><a href="#how-floated-elements-position-themselves">How Floated Elements Position Themselves</a></li>
<li><a href="#how-parents-interact-with-floats">How Parents Interact with Floats</a></li>
<li><a href="#content-avoids-being-under-a-float">Content Avoids Being Under a Float</a></li>
<li><a href="#clearing-the-effect-of-float">Clearing the Effect of Float</a></li>
<li><a href="#how-to-make-a-parent-contain-a-float">How to Make a Parent Contain a Float</a></li>
<li><a href="#clearfix---the-better-way-to-clear-a-float">Clearfix &#8211; The Better Way to Clear a Float</a>
<ol type="1">
<li><a href="#breaking-down-clearfix">Breaking Down Clearfix</a></li>
</ol>
</li>
<li><a href="#summary">Summary</a></li>
<li><a href="#playing-around">Playing Around</a></li>
<li><a href="#references">References</a></li>
</ol>
<h2 id="a-quick-review-of-normal-flow">A Quick Review of Normal Flow</h2>
<p>All HTML elements have a box model:<br />
<img decoding="async" src="https://i0.wp.com/complete-concrete-concise.com/wp-content/uploads/2018/04/15-css-box-model.png?resize=600%2C338&amp;ssl=1" /><br />
All HTML elements are always represented as a rectangle.<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a><br />
Elements can nest one inside the other:</p>
<div style="background: yellow; text-align: center; overflow: auto; font-weight: bold; width: 80%; margin: auto;">
HTML elements</p>
<div style="background: lime; margin: 1em; overflow: auto;">
nested inside</p>
<div style="background: orange; margin: 1em; overflow: auto;">
other</p>
<div style="background: cyan; margin: 1em; overflow: auto;">
elements.
</div>
</div>
</div>
</div>
<p>We call the outer element a <strong>parent</strong> and the inner element a <strong>child</strong>.<br />
In HTML, block elements flow from top to bottom, stacking like blocks:</p>
<p style="margin: auto; width: 150px; background: yellow; text-align: center; vertical-align: middle; line-height: 70px; border: 1px solid black;">HTML Blocks</p>
<p style="margin: auto; width: 150px; line-height: 70px; background: lime; text-align: center; border: 1px solid black;">stack one</p>
<p style="margin: auto; width: 150px; line-height: 70px; background: orange; text-align: center; border: 1px solid black;">atop the</p>
<p style="margin: auto; width: 150px; line-height: 70px; background: cyan; text-align: center; border: 1px solid black;">other</p>
<p>They stack or nest in the order they appear in the HTML document.<a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a><br />
The CSS Box expands to fit whatever is inside it &#8211; whether it is <strong>content</strong> or another CSS Box (which, technically, is content).</p>
<h2 id="float-takes-the-element-out-of-normal-flow"><span class="css-property">float</span> Takes the Element Out of Normal Flow</h2>
<p>When you apply the <span class="css-property">float</span> property to an element, it takes the element out of normal flow.<br />
We have always considered the HTML document to be like a flat sheet of paper. When we <span class="css-property">float</span> an element, it is like adding another sheet of paper on top of the first:<br />
&nbsp;<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/05/26-float-1-min.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3692" src="https://complete-concrete-concise.com/wp-content/uploads/2018/05/26-float-1-min.png" alt="" width="321" height="381" /></a><br />
And the floated element “floats” to that new layer:<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/05/26-float-2.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3693" src="https://complete-concrete-concise.com/wp-content/uploads/2018/05/26-float-2.png" alt="" width="321" height="381" /></a><br />
&nbsp;<br />
Since it is no longer part of the original layer (normal flow), the block elements below move up as if the floated element never existed:<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/05/26-float-3-min.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3694" src="https://complete-concrete-concise.com/wp-content/uploads/2018/05/26-float-3-min.png" alt="" width="321" height="381" /></a><br />
&nbsp;<br />
It is important to understand that the floated element is <strong>no longer <em>fully</em> contained</strong> inside the CSS Box it was declared. It literally <strong>floats</strong> on top of the other HTML elements.<br />
Consider the following styling<a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a> and code:</p>
<div id="cb1" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb1-1" class="sourceLine" data-line-number="1"></a><span class="fu">.box</span> {
<a id="cb1-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">width</span>:<span class="dv">300px</span>;
<a id="cb1-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">height</span>: <span class="dv">150px</span>;
<a id="cb1-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">background-color</span>: <span class="dv">blue</span>;
<a id="cb1-5" class="sourceLine" data-line-number="5"></a>  <span class="kw">margin</span>: <span class="dv">auto</span>;
<a id="cb1-6" class="sourceLine" data-line-number="6"></a>}
<a id="cb1-7" class="sourceLine" data-line-number="7"></a>
<a id="cb1-8" class="sourceLine" data-line-number="8"></a><span class="fu">.floated-box</span> {
<a id="cb1-9" class="sourceLine" data-line-number="9"></a>  <span class="kw">width</span>: <span class="dv">150px</span>;
<a id="cb1-10" class="sourceLine" data-line-number="10"></a>  <span class="kw">height</span>: <span class="dv">300px</span>;
<a id="cb1-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">background-color</span>: <span class="fu">rgba</span>(<span class="dv">255</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0.5</span>);
<a id="cb1-12" class="sourceLine" data-line-number="12"></a>  <span class="kw">float</span>: <span class="dv">left</span>;
<a id="cb1-13" class="sourceLine" data-line-number="13"></a>}</code></pre>
</div>
<div id="cb2" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb2-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"box"</span><span class="kw">&gt;</span>
<a id="cb2-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb2-3" class="sourceLine" data-line-number="3"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Which results in:</p>
<div id="example" style="background: white; border: 1px solid black; padding: 1em;">
<div style="width: 300px; height: 150px; background-color: blue; margin: auto;">
<div style="width: 150px; height: 200px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
</div>
<div style="clear: both;"></div>
</div>
<p>If we switch the <span class="css-property">float</span> from <span class="css-value">left</span> to <span class="css-value">right</span> we get:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="width: 300px; height: 150px; background-color: blue; margin: auto;">
<div style="width: 150px; height: 200px; background-color: rgba(255, 0, 0, 0.5); float: right;"></div>
</div>
<div style="clear: both;"></div>
</div>
<p>In both cases, it should be obvious that the red element is floating above the blue element.</p>
<h2 id="float-changes-the-elements-display-property"><span class="css-property">float</span> Changes the Element’s <span class="css-property">display</span> Property</h2>
<p>All floated elements have a <span class="css-property">display</span> of <span class="css-value">block</span>.<br />
This happens automatically.<br />
You can set it to <span class="css-value">none</span> to hide the floated element, but you cannot set it to <span class="css-value">inline</span> or <span class="css-value">inline-block</span>.<a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a></p>
<h2 id="how-floated-elements-position-themselves">How Floated Elements Position Themselves</h2>
<p>A floating element’s position is bounded by its parent’s top and side edge, according to the following rules:</p>
<ol type="1">
<li>It moves up as high as it can:
<ul>
<li>it stops when it reaches the top of its parent (illustrated in the <a href="#example">examples above</a>) or</li>
<li>it stops when it encounters an HTML element that is not floated:
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="width: 300px; height: 150px; background-color: blue; margin: auto;">
<div style="border: 1px solid black; background: lime;">Not floating.</div>
<div style="width: 150px; height: 200px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
</div>
<div style="clear: both;"></div>
</div>
</li>
</ul>
</li>
<li>It moves as far to the left (or right &#8211; depending on the value of the <span class="css-property">float</span> property) as it can:
<ul>
<li>it stops when it encounters the corresponding side of its parent (illustrated in the <a href="#example">examples above</a>) or</li>
<li>it stops when it encounters the side of another floated element
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="width: 300px; height: 150px; background-color: blue; margin: auto;">
<div style="border: 1px solid black; background: lime; float: left;">Floating</div>
<div style="width: 150px; height: 200px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
</div>
<div style="clear: both;"></div>
</div>
</li>
</ul>
</li>
<li>Since it is removed from <strong>normal flow</strong> the parent knows nothing about the child, so the parent cannot automatically size to contain the floating child. Remember, the child is floating above the parent</li>
<li>It is possible for a floating child’s CSS Box to be larger than its parent’s CSS Box:</li>
</ol>
<div id="example" style="background: white; border: 1px solid black; padding: 1em;">
<div style="width: 200px; height: 150px; background-color: blue; margin: auto;">
<div style="width: 250px; height: 200px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
</div>
<div style="clear: both;"></div>
</div>
<h2 id="how-parents-interact-with-floats">How Parents Interact with Floats</h2>
<p>Because floated elements are removed from <strong>normal flow</strong> they do not affect the parent.<br />
Normally, a parent expands to contain all the content within it (assuming you haven’t set the <span class="css-property">width</span> or <span class="css-property">height</span>), but since a floated element is not contained by the parent, the parent cannot expand to contain it.<br />
We see the parent and child in the examples above because I set the <span class="css-property">width</span> and <span class="css-property">height</span> or the parent element.<br />
Consider the following in which the parent only has the <span class="css-property">background-color</span> set:</p>
<div id="cb3" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb3-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"blue-bg"</span><span class="kw">&gt;</span>
<a id="cb3-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb3-3" class="sourceLine" data-line-number="3"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Which results in:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: rgba(0, 0, 255, 0.5); margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
</div>
<div style="clear: both;"></div>
</div>
<p>Since the parent has no content (remember the floating child is outside <strong>normal flow</strong>), it has full width and a height of&nbsp; zero pixels (since there is nothing for it to expand around). You can convince yourself of this by adding a border to the parent element &#8211; which will appear as a horizontal line since the height it is zero pixels.<br />
Adding some content to the previous example:</p>
<div id="cb4" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb4-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"blue-bg"</span><span class="kw">&gt;</span>
<a id="cb4-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb4-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;p&gt;</span>This is some text.<span class="kw">&lt;/p&gt;</span>
<a id="cb4-4" class="sourceLine" data-line-number="4"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>We get:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: rgba(0, 0, 255, 1.0); margin: auto; color: white;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.
</p></div>
<div style="clear: both;"></div>
</div>
<p>The parent container expanded to contain the content that was added, but it did not expand to contain the floating element.<br />
Had I added the content before the float, the float would have stopped at the first non-float element and we wouldn’t have the dramatic effect of the float overflowing its parent and the parent <strong>not</strong> adjusting its size to contain the float.<br />
This brings up another interesting property of floats: <strong>content avoids being under a float</strong>.</p>
<h2 id="content-avoids-being-under-a-float">Content Avoids Being Under a FLoat</h2>
<p>Consider the following code:</p>
<div id="cb5" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb5-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"yellow-bg"</span><span class="kw">&gt;</span>
<a id="cb5-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb5-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;p&gt;</span>This is some text.<span class="kw">&lt;/p&gt;</span>
<a id="cb5-4" class="sourceLine" data-line-number="4"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb5-5" class="sourceLine" data-line-number="5"></a>
<a id="cb5-6" class="sourceLine" data-line-number="6"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"lime-bg"</span><span class="kw">&gt;</span>
<a id="cb5-7" class="sourceLine" data-line-number="7"></a>  <span class="kw">&lt;p&gt;</span>This is some text in a lime box.<span class="kw">&lt;/p&gt;</span>
<a id="cb5-8" class="sourceLine" data-line-number="8"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb5-9" class="sourceLine" data-line-number="9"></a>
<a id="cb5-10" class="sourceLine" data-line-number="10"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"orange-bg"</span><span class="kw">&gt;</span>
<a id="cb5-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">&lt;p&gt;</span>This is some text in an orange box.<span class="kw">&lt;/p&gt;</span>
<a id="cb5-12" class="sourceLine" data-line-number="12"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Which gives the following result:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.
</p></div>
<div style="background-color: lime; margin: auto; color: black;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
<div style="clear: both;"></div>
</div>
<p>This shows that a float may overlap many CSS Boxes, but the content in those boxes are not covered by the floating element. In other words, content will never appear under a floating element.<a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a><br />
Floating elements <strong>never</strong> cover up content like this:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); position: absolute;"></div>
<p>This is some text.
</p></div>
<div style="background-color: lime; margin: auto; color: black;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
<div style="clear: both;"></div>
</div>
<p>This behaviour makes floats extra confusing because the behaviour of things under a float is not consistent:</p>
<ul>
<li>CSS Boxes can be overlapped by floating elements</li>
<li><strong>Content</strong> in CSS Boxes cannot be overlapped by floating elements</li>
</ul>
<h2 id="clearing-the-effect-of-float">Clearing the Effect of Float</h2>
<p>The <span class="css-property">clear</span> property is used to “restore” <strong>normal flow</strong> around a floated element. This is not technically correct, what really happens is the element is positioned under the bottom margin of the floating element. In other words, <span class="css-property">clear</span> means something like: <strong>position yourself clear of the overlapping effect of any float</strong>.<br />
There are 4 possible values:</p>
<ul>
<li><span class="css-value">none</span> : this is the default value and does not cause the element to get clear of any floats</li>
<li><span class="css-value">left</span> : this causes the HTML element to position itself so it is clear of any <span class="css-property">float:left</span> elements, i.e.&nbsp;no <span class="css-value">left</span> floating element overlaps its CSS Box</li>
<li><span class="css-value">right</span> : this causes the HTML element to position itself so it is clear of any <span class="css-property">float:right</span> elements, i.e.&nbsp;no <span class="css-value">right</span> floating element overlaps its CSS Box</li>
<li><span class="css-value">both</span> : this causes the HTML element to position itself so it is clear of all floating elements, i.e.&nbsp;no floating element overlaps its CSS Box. This is the most commonly used value</li>
</ul>
<p>The <span class="css-property">clear</span> property is applied to the element you want to position <strong>immediately below</strong> the bottom margin of the floating element. Remember that HTML elements flow from top to bottom.<br />
If <span class="css-property">clear</span> is applied to an element that is not covered by a float, then it has no effect on its positioning.<br />
Consider the previous example:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.
</p></div>
<div style="background-color: lime; margin: auto; color: black;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
<div style="clear: both;"></div>
</div>
<p>The red floating box overlaps the yellow, green, and orange HTML elements. Also notice that the <strong>content</strong> does not appear under the floating box.<br />
The red box is a child of the yellow element. It was declared inside the yellow element and is bound to the top and left of the yellow element. But the yellow parent does not enclose its red child because the child is outside of <strong>normal flow</strong>, so the parent isn’t aware of it.<br />
If we want the green element to appear after the floating red box (i.e., we want it to get <span class="css-value">clear</span> of any overlapping by a float), we apply the following style to it:</p>
<div id="cb6" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb6-1" class="sourceLine" data-line-number="1"></a><span class="fu">.clear</span> {
<a id="cb6-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">clear</span>: <span class="dv">both</span>;
<a id="cb6-3" class="sourceLine" data-line-number="3"></a>}</code></pre>
</div>
<p>And apply the class to our code:</p>
<div id="cb7" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb7-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"yellow-bg"</span><span class="kw">&gt;</span>
<a id="cb7-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb7-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;p&gt;</span>This is some text.<span class="kw">&lt;/p&gt;</span>
<a id="cb7-4" class="sourceLine" data-line-number="4"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb7-5" class="sourceLine" data-line-number="5"></a>
<a id="cb7-6" class="sourceLine" data-line-number="6"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"lime-bg clear"</span><span class="kw">&gt;</span>
<a id="cb7-7" class="sourceLine" data-line-number="7"></a>  <span class="kw">&lt;p&gt;</span>This is some text in a lime box.<span class="kw">&lt;/p&gt;</span>
<a id="cb7-8" class="sourceLine" data-line-number="8"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb7-9" class="sourceLine" data-line-number="9"></a>
<a id="cb7-10" class="sourceLine" data-line-number="10"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"orange-bg"</span><span class="kw">&gt;</span>
<a id="cb7-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">&lt;p&gt;</span>This is some text in an orange box.<span class="kw">&lt;/p&gt;</span>
<a id="cb7-12" class="sourceLine" data-line-number="12"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Which gives the following result:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.
</p></div>
<div style="background-color: lime; margin: auto; color: black; clear: both;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
</div>
<p><span class="css-property">clear:both</span> has caused the green element to be positioned just beneath the bottom margin of the floated element. In other words, it got clear of the float. In this example, <span class="css-property">clear:left</span> would have been good enough. Had we used <span class="css-property">clear:right</span>, the green box would not have moved clear of the red box.<br />
Had we also applied <span class="css-class">.clear</span> to the orange box, it would have no effect because the orange box is no longer under the influence of the float.</p>
<h2 id="how-to-make-a-parent-contain-a-float">How to Make a Parent Contain a Float</h2>
<p>We saw that applying <span class="css-property">clear</span> to an HTML element caused it to be positioned below the bottom margin of a floating element.<br />
We can use the same technique to push down the bottom of a parent so it “contains” its floating child. Technically speaking, it doesn’t contain the child &#8211; it only looks like it contains the child.<br />
It is useful to remember:</p>
<ol type="1">
<li>floated elements are not part of <strong>normal flow</strong>.</li>
<li>floated elements float on top of any <strong>normal flow</strong> CSS Boxes below them.</li>
<li>floated elements move as far up as they can in their parent HTML element (this could be a <span class="html-tag">div</span> or even the <span class="html-tag">body</span>). They stop if they encounter a non-floating element.</li>
<li>floated elements move as far to the side (<span class="css-value">left</span> or <span class="css-value">right</span>) as they can. They stop when they either encounter the side <span class="css-property">margin</span> of the parent or of another <span class="css-property">float</span>.</li>
<li><strong>Content</strong> never appears under a floating element. It will always shift to a position where it is not covered by a floating element.</li>
<li>HTML elements expand (assuming no <span class="css-property">width</span> or <span class="css-property">height</span> has been set) to fit their content.</li>
<li>we can set the <span class="css-property">clear</span> property on an HTML element to tell it to position itself so it is clear of (not covered by) a floating element</li>
</ol>
<p>Based on the behaviours outlined above, all that is needed to get a parent to “contain” a floating child is to:</p>
<ul>
<li>place an HTML element inside the parent,</li>
<li>place it after the floating element,</li>
<li>set the <span class="css-property">clear</span> property on it.</li>
</ul>
<p>This will cause the element to position itself after the floating element. Since this element is contained by the parent, the parent will expand to contain it:</p>
<div id="cb8" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb8-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"yellow-bg"</span><span class="kw">&gt;</span>
<a id="cb8-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb8-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;p&gt;</span>This is some text.<span class="kw">&lt;/p&gt;</span>
<a id="cb8-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">&lt;p</span><span class="ot"> class=</span><span class="st">"clear"</span><span class="kw">&gt;</span>Clearing element under
<a id="cb8-5" class="sourceLine" data-line-number="5"></a>    the float that expands the parent
<a id="cb8-6" class="sourceLine" data-line-number="6"></a>  <span class="kw">&lt;/p&gt;</span>
<a id="cb8-7" class="sourceLine" data-line-number="7"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb8-8" class="sourceLine" data-line-number="8"></a>
<a id="cb8-9" class="sourceLine" data-line-number="9"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"lime-bg"</span><span class="kw">&gt;</span>
<a id="cb8-10" class="sourceLine" data-line-number="10"></a>  <span class="kw">&lt;p&gt;</span>This is some text in a lime box.<span class="kw">&lt;/p&gt;</span>
<a id="cb8-11" class="sourceLine" data-line-number="11"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb8-12" class="sourceLine" data-line-number="12"></a>
<a id="cb8-13" class="sourceLine" data-line-number="13"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"orange-bg"</span><span class="kw">&gt;</span>
<a id="cb8-14" class="sourceLine" data-line-number="14"></a>  <span class="kw">&lt;p&gt;</span>This is some text in an orange box.<span class="kw">&lt;/p&gt;</span>
<a id="cb8-15" class="sourceLine" data-line-number="15"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Which gives the following result:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.</p>
<p style="clear: both;">Clearing element under the float that expands the parent</p>
</div>
<div style="background-color: lime; margin: auto; color: black; clear: both;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
</div>
<p>It works, except that we may not want to have text at the bottom of our parent. The trick is to insert a zero pixel high element &#8211; an empty <span class="html-tag">div</span> element works perfectly for this:</p>
<div id="cb9" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb9-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"yellow-bg"</span><span class="kw">&gt;</span>
<a id="cb9-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb9-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;p&gt;</span>This is some text.<span class="kw">&lt;/p&gt;</span>
<a id="cb9-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"clear"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb9-5" class="sourceLine" data-line-number="5"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb9-6" class="sourceLine" data-line-number="6"></a>
<a id="cb9-7" class="sourceLine" data-line-number="7"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"lime-bg"</span><span class="kw">&gt;</span>
<a id="cb9-8" class="sourceLine" data-line-number="8"></a>  <span class="kw">&lt;p&gt;</span>This is some text in a lime box.<span class="kw">&lt;/p&gt;</span>
<a id="cb9-9" class="sourceLine" data-line-number="9"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb9-10" class="sourceLine" data-line-number="10"></a>
<a id="cb9-11" class="sourceLine" data-line-number="11"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"orange-bg"</span><span class="kw">&gt;</span>
<a id="cb9-12" class="sourceLine" data-line-number="12"></a>  <span class="kw">&lt;p&gt;</span>This is some text in an orange box.<span class="kw">&lt;/p&gt;</span>
<a id="cb9-13" class="sourceLine" data-line-number="13"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>Resulting in:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.</p>
<div style="clear: both;"></div>
</div>
<div style="background-color: lime; margin: auto; color: black; clear: both;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
</div>
<p>Which is exactly what we would like &#8211; almost.<br />
The problem is that we have to insert some styled HTML code that does nothing but clear the effect of the float. Effectively, it is “noise” in our code.<br />
Fortunately, there is a better way.</p>
<h2 id="clearfix---the-better-way-to-clear-a-float">Clearfix &#8211; The Better Way to Clear a Float</h2>
<p>The problem with the previous solution is that it adds extra code to get a parent to “wrap around” a floating child. It would be better if we didn’t have to add extra code.<br />
There is a way to do this and it is known as <span class="css-class">.clearfix</span>.<a id="fnref6" class="footnote-ref" href="#fn6"><sup>6</sup></a><br />
The code looks like this (the class name is arbitrary, you are free to call it whatever you like):</p>
<div id="cb10" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb10-1" class="sourceLine" data-line-number="1"></a><span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb10-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">clear</span>: <span class="dv">both</span>;
<a id="cb10-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">display</span>: <span class="dv">block</span>;
<a id="cb10-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">content</span>: <span class="st">""</span>;
<a id="cb10-5" class="sourceLine" data-line-number="5"></a>}</code></pre>
</div>
<p>It is applied to the <strong>parent</strong> containing the floating element:</p>
<div id="cb11" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb11-1" class="sourceLine" data-line-number="1"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"yellow-bg clearfix"</span><span class="kw">&gt;</span>
<a id="cb11-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"floated-box"</span><span class="kw">&gt;&lt;/div&gt;</span>
<a id="cb11-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;p&gt;</span>This is some text.<span class="kw">&lt;/p&gt;</span>
<a id="cb11-4" class="sourceLine" data-line-number="4"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb11-5" class="sourceLine" data-line-number="5"></a>
<a id="cb11-6" class="sourceLine" data-line-number="6"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"lime-bg"</span><span class="kw">&gt;</span>
<a id="cb11-7" class="sourceLine" data-line-number="7"></a>  <span class="kw">&lt;p&gt;</span>This is some text in a lime box.<span class="kw">&lt;/p&gt;</span>
<a id="cb11-8" class="sourceLine" data-line-number="8"></a><span class="kw">&lt;/div&gt;</span>
<a id="cb11-9" class="sourceLine" data-line-number="9"></a>
<a id="cb11-10" class="sourceLine" data-line-number="10"></a><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">"orange-bg"</span><span class="kw">&gt;</span>
<a id="cb11-11" class="sourceLine" data-line-number="11"></a>  <span class="kw">&lt;p&gt;</span>This is some text in an orange box.<span class="kw">&lt;/p&gt;</span>
<a id="cb11-12" class="sourceLine" data-line-number="12"></a><span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>And gives us the result we want:</p>
<div style="background: white; border: 1px solid black; padding: 1em;">
<div style="background-color: yellow; margin: auto;">
<div style="width: 150px; height: 95px; background-color: rgba(255, 0, 0, 0.5); float: left;"></div>
<p>This is some text.</p>
<div style="clear: both;"></div>
</div>
<div style="background-color: lime; margin: auto; color: black; clear: both;">
This is some text in a lime box.
</div>
<div style="background-color: orange; margin: auto; color: black;">
This is some text in a orange box.
</div>
</div>
<h3 id="breaking-down-clearfix">Breaking Down Clearfix</h3>
<p>Unfortunately, <span class="css-class">.clearfix</span> contains CSS elements I am not going to cover in this <a href="https://complete-concrete-concise.com/category/tutorials/webdev/front-end-basics">Front-End Basics</a> tutorial series, but, understanding what is going on with <span class="css-class">.clearfix</span> is important, so I need to give you a little background on what is happening:</p>
<div id="cb12" class="sourceCode">
<pre class="sourceCode css"><code class="sourceCode css"><a id="cb12-1" class="sourceLine" data-line-number="1"></a><span class="fu">.clearfix</span><span class="in">::after</span> {
<a id="cb12-2" class="sourceLine" data-line-number="2"></a>  <span class="kw">clear</span>: <span class="dv">both</span>;
<a id="cb12-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">display</span>: <span class="dv">block</span>;
<a id="cb12-4" class="sourceLine" data-line-number="4"></a>  <span class="kw">content</span>: <span class="st">""</span>;
<a id="cb12-5" class="sourceLine" data-line-number="5"></a>}</code></pre>
</div>
<ul>
<li><span class="css-pseudo-element">::after</span> &#8211; this creates a pseudo-element that is inserted as the last child. In other words, it creates a “fake” HTML element that becomes the last child of the parent. In effect, it automatically inserts the needed last HTML element for us.<a id="fnref7" class="footnote-ref" href="#fn7"><sup>7</sup></a></li>
<li><span class="css-property">clear:both</span> &#8211; this instructs the pseudo-element (which is also the last element) to get clear of any floats. This means the pseudo-element will appear below any floats, thus extending the parent CSS Box around it (because it is contained by the parent).</li>
<li><span class="css-property">display:block</span> &#8211; the pseudo-element display type is set to <span class="css-value">block</span> style because <strong>normal flow</strong> (pretty much) relies on HTML elements being blocks.</li>
<li><span class="css-property">content</span> &#8211; the <span class="css-property">content</span> property allows inserting <strong>content</strong> into the <span class="css-pseudo-element">::after</span> pseudo-element. In fact, there is no other way to insert <strong>content</strong>.<a id="fnref8" class="footnote-ref" href="#fn8"><sup>8</sup></a> In this case, we insert an empty string &#8211; it occupies no space, so the element has a height of zero pixels. If you omit the <span class="css-property">content</span> property. then the <span class="css-class">.clearfix</span> won’t work. Instead of an empty string, you could also use a single space <span class="css-value">&#8221; “</span>.<a id="fnref9" class="footnote-ref" href="#fn9"><sup>9</sup></a></li>
</ul>
<h2 id="summary">Summary</h2>
<ol type="1">
<li>Floated elements are not part of <strong>normal flow</strong>.</li>
<li><span class="css-value">block</span> elements move up to fill the space left by the floated element.</li>
<li>Floated elements automatically have their <span class="css-property">display</span> value set to <span class="css-value">block</span></li>
<li>Floated elements “float up” to a display layer above the document layer.</li>
<li>Floated elements cover any <strong>normal flow</strong> CSS Box elements below them.</li>
<li>Floated elements first move up as far as they can in their parent HTML element. They stop when they reach the top margin of their parent or the bottom margin of a non-floating element.</li>
<li>Floated elements then move as far to the side (<span class="css-value">left</span> or <span class="css-value">right</span>) as they can in their parent HTML element. They stop when they reach the side margin of the parent or of another floating element.</li>
<li>Floated elements are not contained inside their parents, so the parent element does not expand to contain the floating element. (But they are bounded by the top and one side of the parent.)</li>
<li>The CSS Box of a floating child element can be larger than the CSS Box of its parent.
<ul>
<li>the bottom of a floating element can extend below the bottom of its parent.</li>
<li><span class="css-value">left</span> floated elements can have their right margin extend past the right margin of their parent.</li>
<li><span class="css-value">right</span> floated elements can have their left margin extend past the left margin of their parent.</li>
</ul>
</li>
<li><strong>Content</strong> never appears under a floating element. It will always shift to a position where it is not covered by a floating element.</li>
<li>The <span class="css-property">clear</span> property does not stop or end the effect of a floating element.</li>
<li>Setting <span class="css-property">clear:left</span> on an HTML element instructs the element to position itself immediately below any <span class="css-property">float:left</span> elements it may be affected by. If the element is not under the influence of any <span class="css-property">float:left</span> element, this setting has no effect.</li>
<li>Setting <span class="css-property">clear:right</span> on an HTML element instructs the element to position itself immediately below any <span class="css-property">float:right</span> elements it may be affected by. If the element is not under the influence of any <span class="css-property">float:right</span> element, this setting has no effect.</li>
<li>Setting <span class="css-property">clear:both</span> on an HTML element instructs the element to position itself immediately below any floating elements it may be affected by. If the element is not under the influence of any floating elements, this setting has no effect.</li>
<li>Inserting a “dummy” HTML block as the last element in a parent with the <span class="css-property">clear</span> property set will cause the parent to expand and “contain” any floating children.</li>
<li><span class="css-class">.clearfix</span> is the preferred method for getting a parent to “contain” floating child elements.</li>
</ol>
<p>We covered quite a lot of material and information on <span class="css-property">float</span>, but don’t worry, there is still plenty more in the next tutorial.</p>
<h2 id="playing-around">Playing Around</h2>
<p>The best way to learn is to play around with what you have learned.<br />
Floats can be confusing because they are removed from <strong>normal flow</strong> and can overlap other CSS Boxes, but the <strong>content</strong> in those boxes will not be overlapped &#8211; it will be positioned so it is not under a floating element.<br />
For these exercises, I suggest making things simple by:</p>
<ul>
<li>using fixed sized boxes with different coloured backgrounds.</li>
<li>make the background of floating elements semi-transparent using the RGBA() function so you can see when it floats over other HTML elements.</li>
</ul>
<ol type="1">
<li>Observing the effect of floats being removed from <strong>normal flow</strong>:
<ul>
<li>Create two stacked (not nested) boxes and observe what happens when you:
<ul>
<li>float the bottom box to the right?</li>
<li>float the bottom box to the left?</li>
<li>float the top box to the right?</li>
<li>float the top box to the left?</li>
</ul>
</li>
<li>Create four stacked (not nested) boxes and what happens when you:
<ul>
<li>float the second from the top to the right?</li>
<li>float the second from the top to the left?</li>
</ul>
</li>
</ul>
</li>
<li>Observing the effect of <span class="css-property">clear</span> on floats:
<ul>
<li>Create three stacked (not nested) boxes. Make the second box twice as tall as the first box. Make the third box very wide. Float the first box <span class="css-value">left</span> and the second box <span class="css-value">right</span> and observe what happens when:
<ul>
<li><span class="css-property">clear:left</span> is applied to the third box?</li>
<li><span class="css-property">clear:right</span> is applied to the third box?</li>
<li><span class="css-property">clear:both</span> is applied to the third box?</li>
</ul>
</li>
</ul>
</li>
<li>Observing that parents do not contain their floating children:
<ul>
<li>Create a parent container with <strong><u>no</u></strong> specified <span class="css-property">width</span> and <span class="css-property">height</span>, but let it have a <span class="css-property">background-color</span>
<ul>
<li>create a floating child box inside that is smaller than the parent. Do you observe the parent <span class="css-property">background-color</span>?</li>
<li>add a border to the parent. Do you observe the border, but not the <span class="css-property">background-color</span>?</li>
<li>what do you observe when you add non-floating elements to the parent? Try adding them before and after the floating child.</li>
</ul>
</li>
</ul>
</li>
<li>Observing the effect of floats on <strong>content</strong>:
<ul>
<li>Create a parent box with a specified <span class="css-property">width</span> and <span class="css-property">height</span>. Inside, create a floating box. The floating box should have a <span class="css-property">width</span> and <span class="css-property">height</span> greater than its parent. Beneath the floating box, add some text content (it is a good idea to put a border around the <strong>content</strong>) and observe what happens when:
<ul>
<li><span class="css-property">float</span> is set to <span class="css-value">none</span>?</li>
<li><span class="css-property">float</span> is set to <span class="css-value">left</span> or <span class="css-value">right</span>?</li>
</ul>
</li>
</ul>
</li>
<li>Observing the positioning of multiple floats:
<ul>
<li>Create a stack of three floating boxes. What happens when:
<ul>
<li>they all have <span class="css-property">float</span> set to <span class="css-value">left</span>?</li>
<li>they all have <span class="css-property">float</span> set to <span class="css-value">right</span>?</li>
</ul>
</li>
</ul>
</li>
</ol>
<h2 id="references">References</h2>
<ol type="1">
<li><a href="https://www.w3.org/TR/CSS2/visuren.html#propdef-float">float</a></li>
<li><a href="https://www.w3.org/TR/CSS2/visuren.html#flow-control">clear</a></li>
<li><a href="https://www.w3.org/TR/CSS2/generate.html#before-after-content">::after</a></li>
<li><a href="https://www.w3.org/TR/CSS2/generate.html#propdef-content">content</a></li>
<li><a href="https://drafts.csswg.org/css-color-3/#rgba-color">RGBA()</a></li>
<li><a href="https://drafts.csswg.org/css-color/#hex-notation">#RRGGBBAA</a></li>
</ol>
<div class="prev">
<a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-introducing-float">Prev</a>
</div>
<div class="next">
<a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-2">Next</a>
</div>
<div class="clear"></div>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">If the width and height are the same, then it will be a square &#8211; a special case of a rectangle &#8211; but it will never be a circle or triangle or any other shape.<a class="footnote-back" href="#fnref1">↩</a></li>
<li id="fn2">In future tutorials you will see that it is possible to rearrange the content using either JavaScript or certain features of CSS3.<a class="footnote-back" href="#fnref2">↩</a></li>
<li id="fn3">I’m using RGBA, which allows you to specify the color and its <strong>opacity</strong>. Opacity is a fancy way of saying how <em>see-through</em> a colour is. For RGBA, it is a value between 0.0 (fully transparent) and 1.0 (fully opaque &#8211; solid).There is a <strong>hexadecimal</strong> version: #RRGGBBAA. The AA value goes between 00 (full transparency) to FF (full opacity). It is a recent addition to the CSS specification and may not be supported by all browsers (especially older ones), so RGBA is a safer bet. You can also use the shorthand form #RGBA if the two digits of each colour are the same &#8211; #3F7A is the same as #33FF77AAThe A stands for <strong>alpha channel</strong>, which is the standard name for opacity or transparency.<a class="footnote-back" href="#fnref3">↩</a></li>
<li id="fn4">There are more display modes than <span class="css-value">inline</span>, <span class="css-value">inline-block</span>, <span class="css-value">block</span> or <span class="css-value">none</span> &#8211; we haven’t seen yet. You can change the <span class="css-property">display</span> value to some of those, but the upshot is: <em>whatever you change it to, it must behave in a block like manner</em>.<a class="footnote-back" href="#fnref4">↩</a></li>
<li id="fn5">If you force a float to completely overlap a CSS Box, the content will be pushed outside the boundaries of the float.<a class="footnote-back" href="#fnref5">↩</a></li>
<li id="fn6">Probably, the <a href="http://lists.w3.org/Archives/Public/www-style/2002Aug/0134.html">earliest reference</a> to this fix is from Aug 15, 2002. Unfortunately, the fix, as described doesn’t work because it is applied to the floating element.<a class="footnote-back" href="#fnref6">↩</a></li>
<li id="fn7">Before CSS3, it was written <span class="css-pseudo-element">:after</span> (a single colon), but in CSS3, the correct way to write it is <span class="css-pseudo-element">::after</span> (with two colons).<a class="footnote-back" href="#fnref7">↩</a></li>
<li id="fn8">You can use JavaScript to insert content.<a class="footnote-back" href="#fnref8">↩</a></li>
<li id="fn9">Some older browsers had a bug that would not correctly display the empty string, but would if it was a single space. Another alternative is to set the <span class="css-property">font-size</span> and <span class="css-property">height</span> to <span class="css-value">0</span>.<a class="footnote-back" href="#fnref9">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/front-end-basics/css-understanding-how-float-works-part-1/">CSS &#8211; Understanding How Float Works &#8211; Part 1</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Understanding the Difference Between &#034;Front-End&#034;, &#034;Back-End&#034;, and &#034;Full-Stack&#034;.</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-the-difference-between-front-end-back-end-and-full-stack/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Fri, 16 Mar 2018 16:02:04 +0000</pubDate>
				<category><![CDATA[Introduction]]></category>
		<category><![CDATA[back-end]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[full-stack]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3435</guid>

					<description><![CDATA[<p>Learn what Front-End, Back-End, and Full-Stack mean.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-the-difference-between-front-end-back-end-and-full-stack/">Understanding the Difference Between &quot;Front-End&quot;, &quot;Back-End&quot;, and &quot;Full-Stack&quot;.</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
The terms <strong>Front-End</strong>, <strong>Back-End</strong>, and <strong>Full-Stack</strong> come up often in Web Development.<br />
What do they mean?
</div>
<h2 id="front-end">Front End</h2>
<p>Front-End, basically, means everything that happens in the browser. This includes the page design (layout, colours, typography), behaviour, and implementation.<br />
HTML, CSS, and JavaScript are the three main technologies used in front-end development:</p>
<ul>
<li>HTML is the foundation on which all webpages are built, so it is essential.</li>
<li>CSS allows you to customize the look of HTML. It is not essential, but webpages without CSS look very plain.</li>
<li>JavaScript is not essential, but it allows you to add special behaviour to a webpage that is not possible using HTML and CSS alone. Many websites can be built without using JavaScript.</li>
</ul>
<p>In addition to those three technologies, a front-end developer will likely use additional technology in the form of frameworks, libraries, and tools such as:</p>
<ul>
<li>jQuery</li>
<li>Bootstrap</li>
<li>express.js</li>
<li>SASS</li>
<li>LESS</li>
<li>YAML</li>
<li>AngularJS</li>
<li>AJAX</li>
</ul>
<p>Front-end development can be as simple as basic a webpage, as complicated as managing a database<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a>, or as challenging as writing a game.<br />
Front-end development can be, roughly, divided into:</p>
<ul>
<li><strong>Design</strong>: the layout, look, colours, typography, usability</li>
<li><strong>Implementation</strong>: turning the design into something functional</li>
</ul>
<p>As well, front-end development skills can also be used for writing browser extensions for Mozilla Firefox, Google Chrome, Microsoft Edge, and Apple Safari &#8211; because they all use HTML, CSS and JavaScript.<br />
In the past, there were more front-end technologies, but these are, effectively, obsolete:</p>
<ul>
<li>VBScript</li>
<li>ActionScript</li>
<li>Flash</li>
<li>Java</li>
<li>and others</li>
</ul>
<h2 id="back-end">Back-End</h2>
<p>Back-End, basically, means everything that happens on the server. This mostly involves database work and processing data on the server to be sent to the browser.<br />
A programming language (or two), a database, and server software are the main technologies used in back-end development. However, there is a lot more variety in back-end technology than in front-end technology.<br />
Much of the skills and knowledge of front-end development are also applicable for back-end work because the back-end (<strong>server</strong>) has to send HTML pages to the front-end (browser or <strong>client</strong>).<br />
In terms of programming languages, the following are commonly used for back-end development:</p>
<ul>
<li>PHP</li>
<li>Python</li>
<li>Ruby</li>
<li>Java</li>
<li>C#</li>
<li>C++</li>
<li>Perl</li>
<li>Scala</li>
<li>JavaScript</li>
<li>and many more</li>
</ul>
<p>Relational and non-relational databases are used (though, usually not on the same project):</p>
<ul>
<li>MySQL</li>
<li>MariaDB</li>
<li>MongoDB</li>
<li>and many others</li>
</ul>
<p>There is also the server technology that is used:</p>
<ul>
<li>Apache</li>
<li>nginx</li>
<li>node.js</li>
<li>and many more</li>
</ul>
<p>There are also many frameworks and libraries that are used:</p>
<ul>
<li>WordPress</li>
<li>Django</li>
<li>Ruby on Rails</li>
<li>Laravel</li>
<li>Symfony</li>
<li>CodeIgnitor</li>
<li>KOA</li>
<li>Flask</li>
<li>and many more</li>
</ul>
<p>Backend-end development can be, roughly, divided into:</p>
<ul>
<li><strong>Database Design</strong>: the structure of the database</li>
<li><strong>Application Coding</strong>: this is the algorithms, processing, and flow of data through the back-end. This may be even further subdivided.</li>
<li><strong>Glue Coding</strong>: this is code that binds the database, application, and server technology together</li>
<li><strong>Server</strong>: for most small installations, the default configuration of the server is often “good enough” (assuming it has been properly secured). However, for larger servers, or more complex tasks, there can be custom server development and configuration. While this could be lumped together with <strong>Application Coding</strong> it is a sufficiently complex task that needs to be done independently of everything else</li>
</ul>
<h2 id="full-stack">Full-Stack</h2>
<p>Full-Stack refers the <em>full-stack of technology</em>, which is everything from the front-end all the way to the back-end.<br />
So full-stack means everything that occurs on the server, in the browser and everything in between.<br />
While there is a lot of technology involved (not to mention design issues), it is possible to learn enough to be a proficient full-stack developer. It is not about learning everything, it is about learning enough to do what you need.</p>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">HTML5 browsers have a database called IndexDB that can be used for managing data on the <strong>client</strong> side. A common use is to replicate much of the functionality of the <strong>server</strong> so that even if the <strong>client</strong> is not connected to the <strong>Internet</strong>, the web application can still be used. This is becoming increasingly important as people expect their apps to always work.<a class="footnote-back" href="#fnref1">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-the-difference-between-front-end-back-end-and-full-stack/">Understanding the Difference Between &quot;Front-End&quot;, &quot;Back-End&quot;, and &quot;Full-Stack&quot;.</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Understanding How the World Wide Web (WWW) Works</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-how-the-world-wide-web-www-works/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Tue, 06 Mar 2018 14:55:53 +0000</pubDate>
				<category><![CDATA[Introduction]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[uri]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[world wide web]]></category>
		<category><![CDATA[www]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3411</guid>

					<description><![CDATA[<p>A high level overview of the technologies that are the foundation of how the World Wide Web works.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-how-the-world-wide-web-www-works/">Understanding How the World Wide Web (WWW) Works</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">The Internet and the World Wide Web are not the same things, even though people often use these terms interchangeably. The Web is a collection of webpages, videos, pictures, and applications that are all connected together, while the Internet is a global network of devices that can send and receive data.</div>
<h2 id="a-little-background">A Little Background</h2>
<p>In the 1980s, Sir Tim Berners-Lee was working at CERNfound it difficult to access documents and information from different computers:</p>
<blockquote><p>I found it frustrating that in those days, there was different information on different computers, but you had to log on to different computers to get at it. Also, sometimes you had to learn a different program on each computer. So finding out how things worked was really difficult.<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a></p></blockquote>
<p>In 1989, he proposed a <strong>hypertext</strong><a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a> based system for accessing, sharing, and linking documents. At that time, the standard practice for document organization was a centralized repository. Sir Tim Berners-Lee proposed to do away with that:</p>
<blockquote><p>[T]he hope would be to allow a pool of information to develop which could grow and evolve with the organisation and the projects it describes. For this to be possible, the method of storage must not place its own restraints on the information. This is why a “web” of notes with links (like references) between them is far more useful than a fixed hierarchical system.<a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a></p></blockquote>
<p>In 1990, he wrote the first <em>web browser</em> and <em>web server</em> and developed three fundamental technologies that form the foundation of the <strong>World Wide Web</strong>:</p>
<ul>
<li><strong>Hypertext Markup Language</strong> (HTML) &#8211; this is used to create webpages.</li>
<li><strong>Uniform Resource Locator</strong> (URL) &#8211; a string of characters used to identify a resource and its location.<a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a></li>
<li><strong>Hypertext Transfer Protocol</strong> (HTTP) &#8211; the protocol by which <strong>HTML</strong> resources are accessed on the <strong>Internet</strong>.</li>
</ul>
<p>While Sir Tim Berners-Lee’s primary concern was for a web of interconnected <strong>hypertext</strong> documents, he realized that many other resources could be interlinked. His implementation was so successful that the <strong>World Wide Web</strong> includes:</p>
<ol type="1">
<li>Documents &#8211; like this webpage</li>
<li>Images &#8211; Flickr allows people to share and access photos</li>
<li>Video &#8211; YouTube allows people to share and access videos</li>
<li>Audio &#8211; Spotify allows people to listen to music</li>
<li>Applications &#8211; Google Docs is an online word processor</li>
</ol>
<p><a href="https://complete-concrete-concise.com/wp-content/uploads/2018/03/understanding-how-the-world-wide-web-work-1-compressor.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3422" src="https://complete-concrete-concise.com/wp-content/uploads/2018/03/understanding-how-the-world-wide-web-work-1-compressor.jpg" alt="" width="600" height="424" /></a><br />
The <a href="http://info.cern.ch/hypertext/WWW/TheProject.html">first website</a> to go live was at CERN in 1991.<br />
By the end of 1991, there were a total of three websites worldwide:</p>
<ol type="1">
<li><a href="http://info.cern.ch/hypertext/WWW/TheProject.html">CERN</a></li>
<li><a href="http://vlib.org/">The World Wide Web Virtual Library</a> (also at CERN)</li>
<li><a href="https://www6.slac.stanford.edu/">Stanford Linear Accelerator Center</a> &#8211; the first North American website.</li>
</ol>
<p>By the end of 1992, there were a total of 10 websites worldwide.<br />
As of early 2023, there are almost 2 billion websites.</p>
<h2 id="the-world-wide-web">The World Wide Web</h2>
<p>The <strong>Internet</strong> is the global network of interconnected devices transferring datagrams<a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a> using the <strong>Internet Protocol</strong> (IP). Most datagrams are transported using the <strong>Transmission Control Protocol</strong> (TCP) protocol.<a id="fnref6" class="footnote-ref" href="#fn6"><sup>6</sup></a><br />
The <strong>World Wide Web</strong> (WWW) is a service that runs on the <strong>Internet</strong>. It is the collection of documents<a id="fnref7" class="footnote-ref" href="#fn7"><sup>7</sup></a> written in <strong>Hypertext Markup Language</strong> (HTML)<a id="fnref8" class="footnote-ref" href="#fn8"><sup>8</sup></a>, identified by a <strong>Uniform Resource Locator</strong> (URL), and transferred using the <strong>Hypertext Transfer Protocol</strong> (HTTP). All of this is done on the <strong>Internet</strong> using <strong>TCP</strong> and <strong>IP</strong>.<br />
<strong>IP</strong> identifies devices on the Internet, <strong>TCP</strong> transports datagrams between them, and <strong>HTTP<a id="fnref9" class="footnote-ref" href="#fn9"><sup>9</sup></a></strong> is used to access content. <strong>TCP</strong> is like a delivery company that transports goods to the correct address, while <strong>HTTP</strong> packages resources so that they can be transported by <strong>TCP</strong> from one device to another. There are other application layer protocols like <strong>FTP</strong>,<a id="fnref10" class="footnote-ref" href="#fn10"><sup>10</sup></a> <strong>SSH</strong>,<a id="fnref11" class="footnote-ref" href="#fn11"><sup>11</sup></a> <strong>SMTP</strong>,<a id="fnref12" class="footnote-ref" href="#fn12"><sup>12</sup></a> <strong>POP3</strong>,<a id="fnref13" class="footnote-ref" href="#fn13"><sup>13</sup></a> that are used on the Internet, but <strong>HTTP</strong> is the most commonly used.</p>
<p><strong>HTTP</strong> is not the only <em>application layer</em> protocol in use on the <strong>Internet</strong>, but it is the most visible. Most people don’t notice (or even know about) other <em>application layer</em> protocols such as: <strong>FTP</strong>,<a id="fnref10" class="footnote-ref" href="#fn10"><sup>10</sup></a> <strong>SSH</strong>,<a id="fnref11" class="footnote-ref" href="#fn11"><sup>11</sup></a> <strong>SMTP</strong>,<a id="fnref12" class="footnote-ref" href="#fn12"><sup>12</sup></a> <strong>POP3</strong>,<a id="fnref13" class="footnote-ref" href="#fn13"><sup>13</sup></a> etc.</p>
<h2 id="hypertext-markup-language-html">Hypertext Markup Language (HTML)</h2>
<p><strong>HTML</strong> is used to write webpages and web applications. It is often combined with <strong>Cascading Style Sheets</strong> (CSS) and <strong>JavaScript</strong> (JS).<a id="fnref14" class="footnote-ref" href="#fn14"><sup>14</sup></a><br />
<strong>HTML</strong> documents are sent by <strong>web servers</strong> and <em>rendered</em> by <strong>web clients</strong> (web browsers) to display the contents of a webpage to a user.<br />
Here&#8217;s an example of a simple webpage:</p>
<div id="cb1" class="sourceCode">
<pre class="sourceCode html"><code class="sourceCode html"><a id="cb1-1" class="sourceLine" data-line-number="1"></a><span class="dt">&lt;!DOCTYPE </span>html<span class="dt">&gt;</span>
<a id="cb1-2" class="sourceLine" data-line-number="2"></a><span class="kw">&lt;html&gt;</span>
<a id="cb1-3" class="sourceLine" data-line-number="3"></a>  <span class="kw">&lt;head&gt;</span>
<a id="cb1-4" class="sourceLine" data-line-number="4"></a>    <span class="kw">&lt;title&gt;</span>A Simple Webpage<span class="kw">&lt;/title&gt;</span>
<a id="cb1-5" class="sourceLine" data-line-number="5"></a>  <span class="kw">&lt;/head&gt;</span>
<a id="cb1-6" class="sourceLine" data-line-number="6"></a>  <span class="kw">&lt;body&gt;</span>
<a id="cb1-7" class="sourceLine" data-line-number="7"></a>    <span class="kw">&lt;h1&gt;</span>This is important!<span class="kw">&lt;/h1&gt;</span>
<a id="cb1-8" class="sourceLine" data-line-number="8"></a>    <span class="kw">&lt;p&gt;</span>Check out this site:<span class="kw">&lt;/p&gt;</span>
<a id="cb1-9" class="sourceLine" data-line-number="9"></a>    <span class="kw">&lt;a</span><span class="ot"> href=</span><span class="st">"//example.com"</span><span class="kw">&gt;</span>Example<span class="kw">&lt;/a&gt;</span>
<a id="cb1-10" class="sourceLine" data-line-number="10"></a>  <span class="kw">&lt;/body&gt;</span>
<a id="cb1-11" class="sourceLine" data-line-number="11"></a><span class="kw">&lt;/html&gt;</span></code></pre>
</div>
<p>All <strong>HTML</strong> documents are composed of <strong>HTML</strong> tags which (usually) come in pairs. There is an opening tag, like <span class="kbd">&lt;html&gt;</span> and its corresponding closing tag <span class="kbd">&lt;/html&gt;</span>. These tags <strong>markup</strong> the document.<br />
<strong>HTML</strong> tags perform three different functions:</p>
<ul>
<li><strong>Structural Markup</strong> tags are used to indicate the structure and purpose of the text in the document. We can see that this page is divided into two parts: a <span class="kbd">&lt;head&gt;</span> that contains <em>metainformation</em><a id="fnref15" class="footnote-ref" href="#fn15"><sup>15</sup></a> about the page and a <span class="kbd">&lt;body&gt;</span> that contains the content displayed to the user. In the body, we see there is a <em>heading</em> (<span class="kbd">&lt;h1&gt;</span>) and a <em>paragraph</em> (<span class="kbd">&lt;p&gt;</span>).</li>
<li><strong>Presentational Markup</strong> is used to indicate how text should be displayed to the user &#8211; for example, <strong>bold</strong>, <em>italic</em>, <del>strikethrough</del>, etc. There is no presentation markup in this simple webpage. <strong>CSS</strong> is recommended for presentation markup.</li>
<li><strong>Hypertext Markup</strong> is used to create links inside the document to other documents or resources. In this page, there is a single hypertext link &#8211; the anchor tag <span class="kbd">&lt;a&gt;</span></li>
</ul>
<p>In general, <strong>HTML</strong> documents are plain text documents with special annotations (<strong>HTML</strong> tags) to describe the structure of the document. <strong>Web clients</strong> (web browsers) display the content to the user.</p>
<h2 id="uniform-resource-locator-url">Uniform Resource Locator (URL)</h2>
<p>A <strong>Uniform Resource Locator</strong> (URL) is used to access resources on the <strong>WWW</strong>. It has the following format:</p>
<pre class="url"><code>&lt;access protocol&gt;://&lt;host&gt;/&lt;location &amp; resource name&gt;</code></pre>
<ul>
<li><strong>access protocol</strong> specifies how the resource is to be accessed. For the <strong>WWW</strong> it is either <strong>HTTP</strong> or <strong>HTTPS</strong><a id="fnref16" class="footnote-ref" href="#fn16"><sup>16</sup></a>. There are many different access protocols for the <strong>Internet</strong>.<a id="fnref17" class="footnote-ref" href="#fn17"><sup>17</sup></a> Technically, you should always include the access protocol when you type the <strong>URL</strong> for a website. However, browsers (being helpful) will automatically prefix the protocol for you.</li>
<li><strong>host</strong> specifies which device on the <strong>Internet</strong> contains the resource. It can be an <strong>IP</strong> address (like <span class="kbd">127.0.0.1</span>) or, more commonly, a human readable string (like <span class="kbd">www.complete-concrete-concise.com</span>) which is translated by a <strong>Domain Name System</strong> (DNS) into an <strong>IP</strong> address.</li>
<li><strong>location &amp; resource name</strong> specifies the name of the resource and where it is located. If no resource name is given, <strong>web servers</strong> return <span class="kbd">index.html</span> by default.</li>
</ul>
<p>Let’s consider the following <strong>URL</strong>:</p>
<pre class="url"><code>https://complete-concrete-concise.com/sample/helloworld.html</code></pre>
<ul>
<li>The <strong>access protocol</strong> is <strong>https</strong>.</li>
<li>The <strong>host</strong> is <strong>complete-concrete-concise.com</strong>.</li>
<li>The <strong>location &amp; resource</strong> is <strong>/sample/helloworld.html</strong>.</li>
</ul>
<h2 id="hypertext-transfer-protocol-http">Hypertext Transfer Protocol (HTTP)</h2>
<p><strong>HTTP</strong> responses indicate the status of a request, with two common responses being 200 (OK) for a successful request and 404 (NOT FOUND) for when the requested resource cannot be found.</p>
<p><strong>HTTP</strong> is a <strong>request-response</strong> protocol for data transfer on the <strong>World Wide Web</strong>. It is most commonly used for transferring hypertext documents, like <strong>HTML</strong>, but can be used to transfer other types of content.</p>
<p>It operates on a <strong>client-server</strong> model. The <strong>client</strong> sends a <em>request</em> to a <strong>server</strong>. The <strong>server</strong> then <em>responds</em> to the <strong>client</strong>. For example, a web browser (<strong>client</strong>) that <em>requests</em> a webpage from a website (<strong>server</strong>); the website (<strong>server</strong>) <em>responds</em> by sending the webpage to the web browser (<strong>client</strong>).<a id="fnref18" class="footnote-ref" href="#fn18"><sup>18</sup></a></p>
<p>It is a stateless protocol.<a id="fnref21" class="footnote-ref" href="#fn21"><sup>19</sup></a> This means that each <strong>HTTP request</strong> is independent of all other <strong>HTTP requests</strong>. In other words, the current <em>request</em> knows nothing about previous requests: all information to fulfill the <em>request</em> must be contained in the request itself.</p>
<p>Two common <strong>HTTP</strong> requests are <strong>GET,</strong> used to request a resource from a server, and <strong>POST,</strong> used to send data to a server, such as when submitting a comment or form.</p>
<p><strong>HTTP</strong> responses indicate the status of a request, with two common responses being 200 (OK) for a successful request and 404 (NOT FOUND) for when the requested resource cannot be found.</p>
<h2 id="summary">Summary</h2>
<ol type="1">
<li>The <strong>World Wide Web</strong> is one of many services that run on top of the <strong>Internet</strong>.</li>
<li>The <strong>World Wide Web</strong> is the global collection of resources written using <strong>Hypertext Markup Language</strong> (HTML),<a id="fnref22" class="footnote-ref" href="#fn22"><sup>20</sup></a> identified using a <strong>Uniform Resource Locator</strong> (URL), and transferred using the <strong>Hypertext Transfer Protocol</strong> (HTTP).</li>
<li><strong>Clients</strong> <em>request</em> resources from <strong>servers</strong> using <strong>HTTP</strong>.</li>
<li><strong>Servers</strong> <em>respond</em> to <strong>clients</strong> using <strong>HTTP</strong>.</li>
<li><strong>HTTP</strong> is transported using <strong>TCP</strong> between devices adhering to the <strong>Internet Protocol</strong>.</li>
<li>The flexibility of <strong>HTTP</strong> has contributed to the <strong>World Wide Web</strong> becoming extremely popular because it handles all types of content: from documents to videos, from images to applications.</li>
</ol>
<h2 id="further-reading">Further Reading</h2>
<p>If you are interested in learning more about, check out the following resources:</p>
<h4 id="world-wide-web">World Wide Web</h4>
<ul>
<li><a href="https://www.w3.org/TR/webarch/">Architecture of the World Wide Web</a></li>
</ul>
<h4 id="uniform-resource-locators">Uniform Resource Locators</h4>
<ul>
<li><a href="https://www.w3.org/TR/uri-clarification/">URIs, URLs, and URNs: Clarifications and Recommendations</a></li>
</ul>
<h4 id="hypertext-transfer-protocol">Hypertext Transfer Protocol</h4>
<ul>
<li><a href="https://tools.ietf.org/html/rfc2616">RFC2616</a> &#8211; this is an older document about the <strong>HTTP/1.1</strong> specification. It is a good place to start because it is all in one place.</li>
</ul>
<p>If you want more information, then the following, more recent, documents give more information. They update RFC2616 and break it down into multiple documents, but may be information overload:</p>
<ul>
<li><a href="https://tools.ietf.org/html/rfc7230">RFC 7230</a> Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</li>
<li><a href="https://tools.ietf.org/html/rfc7231">RFC 7231</a> Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</li>
<li><a href="https://tools.ietf.org/html/rfc7232">RFC 7232</a> Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests</li>
<li><a href="https://tools.ietf.org/html/rfc7233">RFC 7233</a> Hypertext Transfer Protocol (HTTP/1.1): Range Requests</li>
<li><a href="https://tools.ietf.org/html/rfc7234">RFC 7234</a> Hypertext Transfer Protocol (HTTP/1.1): Caching</li>
<li><a href="https://tools.ietf.org/html/rfc7235">RFC 7235</a> Hypertext Transfer Protocol (HTTP/1.1): Authentication</li>
</ul>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">From <a href="https://www.w3.org/People/Berners-Lee/Kids.html">Answers For Young People</a><a class="footnote-back" href="#fnref1">↩</a></li>
<li id="fn2">Hypertext is a type of document that contains links (called hyperlinks) to other documents. These links can be clicked to access the other documents.<a class="footnote-back" href="#fnref2">↩</a></li>
<li id="fn3">From <a href="https://www.w3.org/History/1989/proposal.html">Information Management: A Proposal</a><a class="footnote-back" href="#fnref3">↩</a></li>
<li id="fn4">Strictly speaking, this is untrue. Berners-Lee developed the <strong>Uniform Resource Identifier</strong> (URI). There are many kinds of URIs, two common ones are: <strong>Uniform Resource Name</strong> (URN) and <strong>Uniform Resource Locator</strong> (URL). A <strong>URN</strong> identifies a resource. For example, the book <em>A Tale of Two Cities by Charles Dickens</em> is a <strong>URN</strong>. A <strong>URL</strong>, on the other hand, identifies <em>both</em> the resource and its location. For example, the book <em>A Tale of Two Cities by Charles Dickens can be found at the library on the third bookshelf, second shelf from the bottom, fifth book from the left</em> is a <strong>URL</strong> because it specifies both the resource and its location. A <strong>URN</strong> only specifies the name of a resource. Therefore, all <strong>URLs</strong> are <strong>URIs</strong>, but not all <strong>URIs</strong> are <strong>URLs</strong> (because some <strong>URIs</strong> are <strong>URNs</strong>)<a class="footnote-back" href="#fnref4">↩</a></li>
<li id="fn5">A datagram is a packet of information. The IP datagram consists of a header and a payload.<a class="footnote-back" href="#fnref5">↩</a></li>
<li id="fn6">There are other protocols, but <strong>TCP</strong>’s robustness and reliability make it very popular.<a class="footnote-back" href="#fnref6">↩</a></li>
<li id="fn7">Strictly speaking, this is untrue. The official definition of the <strong>World Wide Web</strong> is “<a href="https://www.w3.org/TR/webarch/#intro">an information space in which the items of interest, referred to as resources, are identified by global identifiers called Uniform Resource Identifiers (URI)</a>”. The official definition is vague on what a “resource is”: “<a href="https://www.w3.org/TR/webarch/#id-resources">We do not limit the scope of what might be a resource.</a>”. However, practically speaking, most, if not all, resources are <strong>HTML</strong> webpages or things that act as if they were <strong>HTML</strong> pages.<a class="footnote-back" href="#fnref7">↩</a></li>
<li id="fn8">It does not have to be <strong>HTML</strong>, it could be <strong>XHTML</strong>, <strong>XML</strong>, <strong>SVG</strong>, or any other <strong>HTML-like</strong> markup language.<a class="footnote-back" href="#fnref8">↩</a></li>
<li id="fn9">Technically, <strong>HTTP</strong> is an <em>application layer</em> protocol and interface. This concept doesn’t translate well into the real, physical world we inhabit. If you give someone a drink of water, it has to be in an <em>interface</em> that is useful &#8211; like a glass. The glass is <strong>HTTP</strong>, giving the person the water in the glass is <strong>TCP</strong>, and the receiver is <strong>IP</strong>. Consider shipping marbles to someone: there is an address (<strong>IP</strong>), a courier company does the delivery (<strong>TCP</strong>), but, in order to ship the marbles, you have to adhere to some conventions (protocols) and package the marbles in a box (interface) (<strong>HTTP</strong>).<a class="footnote-back" href="#fnref9">↩</a></li>
<li id="fn10"><strong>File Transfer Protocol</strong> is used for transferring computer files.<a class="footnote-back" href="#fnref10">↩</a></li>
<li id="fn11"><strong>Secure Shell</strong> provides secure access to a computer over a network.<a class="footnote-back" href="#fnref11">↩</a></li>
<li id="fn12"><strong>Simple Mail Transfer Protocol</strong> is used for transmitting emails.<a class="footnote-back" href="#fnref12">↩</a></li>
<li id="fn13"><strong>Post Office Protocol</strong> is used retrieve email from a remote server.<a class="footnote-back" href="#fnref13">↩</a></li>
<li id="fn14">These will all be covered in greater detail in future tutorials.<a class="footnote-back" href="#fnref14">↩</a></li>
<li id="fn15">Metainformation is information about the document, not the information contained in the document. For example, <em>metainformation</em> about a document could include its: length, language, date of publication, date of last revision, author, etc.<a class="footnote-back" href="#fnref15">↩</a></li>
<li id="fn16"><strong>HTTPS</strong> is the secure form of <strong>HTTP</strong>. Using <strong>HTTPS</strong> ensures all communication between the <strong>client</strong> and <strong>server</strong> is encrypted. Surprisingly, <strong>HTTP</strong> and <strong>HTTPS</strong> access can both occur on the same page. This occurs because <strong>HTML</strong> documents often contains <em>hyperlinks</em> to other documents. Those <em>hyperlinks</em> point to documents that are transmitted using either <strong>HTTP</strong> or <strong>HTTPS</strong>.<a class="footnote-back" href="#fnref16">↩</a></li>
<li id="fn17">A list of official and unofficial protocols can be found <a href="https://www.w3.org/Addressing/schemes">here</a><a class="footnote-back" href="#fnref17">↩</a></li>
<li id="fn18">Actually, the server can respond in a number of different ways. For example, if the webpage is not found, it can respond with a 404 error.<a class="footnote-back" href="#fnref18">↩</a></li>
<li id="fn21">This is true of the <strong>HTTP</strong> protocol itself. Servers tend to log all or part of incoming <strong>HTTP</strong> requests. These logs are for maintenance and forensics, not for keeping track of previous <strong>HTTP</strong> requests. Clients also tend to cache components of the <strong>HTTP</strong> response &#8211; for example: cookies, images, HTML pages, and other resources. These topics will be addressed in future tutorials.<a class="footnote-back" href="#fnref21">↩</a></li>
<li id="fn22">This is mostly true, the documents don’t have to be written in <strong>HTML</strong>, but it does have to be something that &#8211; more or less &#8211; behaves as if it were <strong>HTML</strong> &#8211; for example, <strong>xhtml</strong>.<a class="footnote-back" href="#fnref22">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-how-the-world-wide-web-www-works/">Understanding How the World Wide Web (WWW) Works</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Understanding How the Internet Works</title>
		<link>https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-how-the-internet-works/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Thu, 15 Feb 2018 18:40:55 +0000</pubDate>
				<category><![CDATA[Introduction]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[understanding]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://complete-concrete-concise.com/?p=3380</guid>

					<description><![CDATA[<p>A high level overview of how the Internet Works.</p>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-how-the-internet-works/">Understanding How the Internet Works</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="preamble">
The Internet and the World Wide Web are two different things, although many people confuse the two.<br />
This article provides a high level overview of how the Internet Works.
</div>
<h2 id="the-internet">The Internet</h2>
<p>The Internet is the global network of connected devices that adhere to the <strong>Internet Protocol</strong> (IP).<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-1-600px-80.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3385" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-1-600px-80.jpg" alt="" width="600" height="390" /></a><br />
The <strong>Internet Protocol</strong> allows devices to connect to the Internet and communicate with other devices connected to the Internet. It is a specification for a <span class="mark">basic unit of data transfer</span> or <strong>datagram</strong>.<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-2.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3388" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-2.jpg" alt="" width="600" height="521" /></a><br />
The <strong>IP</strong> datagram consists of a <strong>header</strong> and a <strong>payload</strong>.<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-3.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3390" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-3.jpg" alt="" width="600" height="468" /></a><br />
The <strong>header</strong> has a <strong>source</strong> address and a <strong>destination</strong> address. As a result, there is no true anonymity on the Internet, since the transfer of information requires knowing the source and destination of the information transfer<a id="fnref1" class="footnote-ref" href="#fn1"><sup>1</sup></a>.<br />
The <strong>payload</strong> is the information part of the packet and its content depends on what is being transmitted. It is at the <strong>payload</strong> level that the World Wide Web and other Internet services (like email, Voice over IP (VoIP), File Transfer Protocol (FTP), etc) exist.<br />
The <strong>IP Header</strong> also includes a <strong>transport protocol</strong>. This controls how the <strong>datagram</strong> is transported through the Internet. Two common transport protocols are: <em>Transmission Control Protocol</em> (TCP) and <em>User Datagram Protocol</em> (UDP).<br />
<strong>TCP</strong> is a robust protocol that verifies the packet is received. If the packet is not received, it is retransmitted.<br />
<strong>UDP</strong> is less robust &#8211; it doesn’t verify that the packet is received. This may seem strange, but some data transfers don’t need to be robust &#8211; they can tolerate lost packets. For example, video streaming can survive the occasional “lost” data packet.<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-4.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3393" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-4.png" alt="" width="600" height="393" /></a><br />
The use of TCP on the Internet is sometimes referred to as <strong>tcp/ip</strong> or <strong>TCP/IP</strong>. This is read as <span class="mark">TCP over IP</span>.</p>
<h3 id="ip-addresses">IP Addresses</h3>
<p>Each device connected to the Internet must be uniquely identifiable<a id="fnref2" class="footnote-ref" href="#fn2"><sup>2</sup></a>. This is done by assigning each device on the Internet a unique number called an <strong>IP Address</strong>. There are two types of IP addresses: <strong>IPv4</strong> and <strong>IPv6</strong> &#8211; they are not compatible.<a id="fnref3" class="footnote-ref" href="#fn3"><sup>3</sup></a><br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-5.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3395" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-5.jpg" alt="" width="600" height="720" /></a><br />
<strong>IPv4</strong> is the older and most commonly used (for now) addressing scheme. Each device on the Internet is assigned a unique identifier. This identifier is a 32 bit number. This means there are 2<sup>32</sup> different numbers available. Which means a maximum of 4294967296 devices can be connected to the Internet when using IPv4 addressing<a id="fnref4" class="footnote-ref" href="#fn4"><sup>4</sup></a>.<br />
The addresses are written in <em>dotted</em> notation. This is done by dividing the 32 bit number into four 8 bit octets.<a id="fnref5" class="footnote-ref" href="#fn5"><sup>5</sup></a> Each octet is written in decimal notation separated by a period. IPv4 addresses look similar to these examples: <span class="kbd">127.0.0.1</span> or <span class="kbd">192.168.1.101</span>, or <span class="kbd">10.184.216.34</span>.<br />
<strong>IPv6</strong> is a newer addressing scheme and was introduced to expand the number of available IP addresses.<a id="fnref6" class="footnote-ref" href="#fn6"><sup>6</sup></a> <strong>IPv6</strong> addresses are 128 bits long and allow for 2<sup>128</sup> unique addresses<a id="fnref7" class="footnote-ref" href="#fn7"><sup>7</sup></a>.<br />
<strong>IPv6</strong> addresses are written differently from <strong>IPv4</strong> addresses. The 128 bit address is divided into eight 16 bit hextets.<a id="fnref8" class="footnote-ref" href="#fn8"><sup>8</sup></a> These are written in hexadecimal<a id="fnref9" class="footnote-ref" href="#fn9"><sup>9</sup></a> notation and separated by colons<a id="fnref10" class="footnote-ref" href="#fn10"><sup>10</sup></a>. IPv6 addresses look similar to these examples: <span class="kbd">::1</span><a id="fnref11" class="footnote-ref" href="#fn11"><sup>11</sup></a>, or <span class="kbd">FE80:0000:0000:0000:0202:B3FF:FE1E:8329</span></p>
<h3 id="clients-and-servers">Clients and Servers</h3>
<p>Devices on the Internet are classified as <strong>clients</strong> or <strong>servers</strong><a id="fnref12" class="footnote-ref" href="#fn12"><sup>12</sup></a>.<br />
A <strong>client</strong> requests resources from a server. It tends to have a transitory connection to the Internet and may not always be available.<br />
A <strong>server</strong> provides (serves) resources to clients. It tends to be permanently connected to the Internet and always available.<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-6.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3397" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-6.png" alt="" width="600" height="600" /></a><br />
You can think of the relationship between clients and servers as being similar to the relationship between students and teachers. The students (clients) request information from the teacher (server) and the teacher (server) provides information to the students (clients).<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-8.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3401" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-8.png" alt="" width="600" height="339" /></a><br />
If clients wish to communicate with other clients, the information is sent first to the server and then the server forwards the information to other clients.<br />
There is a third relationship: <strong>peer-to-peer</strong> (P2P). Like clients, peers tend to be characterized by transitory connections to the Internet.<br />
<strong>Peers</strong> are devices that connect directly with other devices instead of going through a <strong>server</strong>. <em>P2P</em> devices act both as server and client. Communication between peers is direct and not mediated by a server.<br />
<a href="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-7.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3399" src="https://complete-concrete-concise.com/wp-content/uploads/2018/02/internet-7.png" alt="" width="600" height="600" /></a></p>
<h3 id="domain-names">Domain Names</h3>
<p>Most people rarely (if ever) access resources on the Internet by entering <strong>IP Addresses</strong>. Addresses like <span class="kbd">192.168.1.1</span> might be fine for computers but they are not easy for humans to use. A <strong>Domain Name</strong> is a string of characters (preferably easy to remember) that act as an alias for an <strong>IP Address</strong>.<br />
Domain names are hierarchically organized. The <strong>Internet Corporation for Assigned Names and Numbers</strong> (ICANN) manages the structure of domain names on the Internet.<br />
Domains are composed of two parts: the <strong>hostname</strong> and the <strong>top-level domain</strong>.<a id="fnref13" class="footnote-ref" href="#fn13"><sup>13</sup></a><br />
For example: <span class="kbd">complete-concrete-concise</span> is the hostname and <span class="kbd">.com</span> is the top-level domain.<br />
The mapping from a <strong>domain name</strong> into an <strong>IP Address</strong> is performed by a <strong>Domain Name System Server</strong> (DNS Server). The <strong>domain name</strong> is sent to the <strong>DNS Server</strong> and the server returns the associated <strong>IP Address</strong>.<a id="fnref14" class="footnote-ref" href="#fn14"><sup>14</sup></a><br />
Globally, there are 13 <em>root servers</em> from which all domain names are resolved.<a id="fnref15" class="footnote-ref" href="#fn15"><sup>15</sup></a></p>
<h3 id="summary">Summary</h3>
<ol>
<li>The Internet is the global network of connected devices which adhere to the <strong>Internet Protocol</strong>.</li>
<li>The Internet Protocol is a <strong>datagram</strong> composed of a <strong>header</strong> and a <strong>payload</strong>.</li>
<li>The <strong>IP header</strong> consists of a <strong>source address</strong>, <strong>destination address</strong>, and a <strong>transport protocol</strong>.</li>
<li>Every device connected to the Internet requires a unique identifying address.</li>
<li>The <strong>IP payload</strong> carries the data for a specific service. This might be the <strong>World Wide Web</strong>, <strong>email</strong>, <strong>Voice over Internet</strong>, or any other service.</li>
<li>The Internet tends to be hierarchical with a <strong>client-server</strong> model.</li>
<li><strong>Clients</strong> request services and resources from the Internet and tend to have a transitory presence on the Internet.</li>
<li><strong>Servers</strong> provide services and resources on the Internet and tend to have a permanent presence on the Internet.</li>
<li><strong>Domain names</strong> are a (human readable) way of accessing resources on the Internet. <strong>Domain names</strong> are sent to a global network of <strong>DNS Servers</strong> that return the <strong>IP Address</strong> associated with the domain.</li>
</ol>
<section class="footnotes">
<hr />
<ol>
<li id="fn1">You can try to make it difficult for someone to follow your trail by going through multiple intermediate connections (for example, by using Tor), but, ultimately, there is a direct path between the <strong>source</strong> and <strong>destination</strong>. It is a lot like playing “connect the dots”. If there are only two dots (source and destination), the connection is easy to follow. If there are multiple intermediate dots, then the path is harder to follow &#8211; but not impossible. A lot depends on whether the various intermediate points store visitor info and how easy it is to get access to that information. A route spanning multiple countries makes it harder to get access to the information &#8211; but not impossible.<a class="footnote-back" href="#fnref1">↩</a></li>
<li id="fn2">This is not entirely true. There are ways multiple devices can “share” the same <strong>IP Address</strong>. This will be covered in a future tutorial.<a class="footnote-back" href="#fnref2">↩</a></li>
<li id="fn3">This means there are two different Internets running side-by-side. Techniques allow traffic to flow between the two, but this will be covered in a future tutorial.<a class="footnote-back" href="#fnref3">↩</a></li>
<li id="fn4">Fewer addresses are actually available because a number of them are reserved. This will be covered in a future tutorial.<a class="footnote-back" href="#fnref4">↩</a></li>
<li id="fn5">An octet is 8 bits.<a class="footnote-back" href="#fnref5">↩</a></li>
<li id="fn6">On January 31, 2011, the <strong>Internet Assigned Numbers Authority</strong> (IANA) allocated the last of the IPv4 address blocks. This didn’t mean the world had run out of IPv4 IP Addresses, but it did mean there were no more available to hand out. Companies and organizations manage blocks of IP addresses which they have been allocated by IANA. There are a number of techniques that can be used to ensure everybody has a unique IP address when connecting to the Internet. This will be covered in more detail in a future tutorial.<a class="footnote-back" href="#fnref6">↩</a></li>
<li id="fn7">This is approximately 3.4&#215;10<sup>38</sup> addresses. As with <strong>IPv4</strong>, some addresses are reserved, so the actual number of available addresses is slightly less. Written out in full it is 340,282,366,920,938,463,463,374,607,431,768,211,456. More details will be given in a future tutorial.<a class="footnote-back" href="#fnref7">↩</a></li>
<li id="fn8">A hextet is 16 bits.<a class="footnote-back" href="#fnref8">↩</a></li>
<li id="fn9">Hexadecimal numbers are numbers written in base 16. In decimal notation, we use 10 unique digits: 0 through 9. Hexadecimal needs 16 unique digits, so we extend the decimal digits by adding the letters A through F as additional digits. In hexadecimal, the number 10 is written as 0xA, the number 15 as 0xF, the number 16 as 0x10. The prefix 0x is used to indicate the number is in hexadecimal notation.<a class="footnote-back" href="#fnref9">↩</a></li>
<li id="fn10">When you write out the address in full. A number of rules allow writing addresses more compactly. This will be covered in more detail in a future tutorial.<a class="footnote-back" href="#fnref10">↩</a></li>
<li id="fn11">This is permitted shorthand for <span class="kbd">0000:0000:0000:0000:0000:0000:0000:0001</span>.<a class="footnote-back" href="#fnref11">↩</a></li>
<li id="fn12">Actually, there are many more devices: routers, gateways, switches. Some of these may be covered in more detail in a future tutorial.<a class="footnote-back" href="#fnref12">↩</a></li>
<li id="fn13">It is a little more complicated and will be covered in more detail in a future tutorial. It is also closely related to the <strong>Universal Resource Locator</strong> (URL) &#8211; also to be covered in a future tutorial.<a class="footnote-back" href="#fnref13">↩</a></li>
<li id="fn14">It can be more complicated than this and will be covered in more detail in a future tutorial.<a class="footnote-back" href="#fnref14">↩</a></li>
<li id="fn15">The 13 <em>root servers</em> are a global network of hundreds of computers dedicated to mapping <strong>domain names</strong> to <strong>IP Addresses</strong>. The network is partitioned among 13 organizations who are responsible for managing their part.<a class="footnote-back" href="#fnref15">↩</a></li>
</ol>
</section>
<p>The post <a href="https://complete-concrete-concise.com/tutorials/webdev/introduction/understanding-how-the-internet-works/">Understanding How the Internet Works</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
