Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML: non-floating auto width navigation
    primarykey
    data
    text
    <p>I'm new to HTML &amp; CSS and one of my first steps is creating a normal layout like</p> <pre><code>/----------------\ | Header | |----------------| | N | | | a | Content | | v | | |----------------| | Foot | \----------------/ </code></pre> <p>In order to be flexible, Navs width shouldn't be fixed and the Content should never float around it. In other words, Nav and Content should behave like table columns just that the use of tables for formatting are a big no no in HTML. My current code looks like this:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Todo list&lt;/title&gt; &lt;style type="text/css"&gt; nav { float: left; padding-right: 5px; margin-right: 5px; background: yellow; height: auto; /* auto | inherit | 100% */ width: auto; } #content { margin: 5px; padding-left: 5px; } header { background: blue; } footer { clear: both; background: #ccc; } .clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;header&gt; Head &lt;/header&gt; &lt;nav id="main_nav"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/contact"&gt;Contact (p)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/temp"&gt;Temp&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;div id="content" class="clearfix"&gt; &lt;h1&gt;Test&lt;/h1&gt; &lt;h2&gt;A&lt;/h2&gt;&lt;h2&gt;C&lt;/h2&gt;&lt;h2&gt;D&lt;/h2&gt; &lt;/div&gt; &lt;footer&gt; &lt;p&gt;[Copyright bumf]&lt;/p&gt; &lt;/footer&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Which results in </p> <p><img src="https://i.stack.imgur.com/i7Ua0.png" alt="uglyNav"></p> <p>Most solutions I found used either a fixed width for Nav or for the Content margin, which isn't a clean. It seems that <a href="http://www.w3.org/TR/css3-multicol/" rel="nofollow noreferrer">CSS Multi-column Layout Module</a> or <a href="http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#flex-containers" rel="nofollow noreferrer">CSS Flexible Box Layout Module</a> could help, but they are both "Candidate Recommendation" so I can't use them safely. What's the proper way to solve my problem?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload