Hello & Thanks ,
In my code below , why is it the Html code
that the <div class="middle"> is specified BEFORE the
<aside class="left-sidebar"> and the <aside class="right-sidebar"> ?
Thanks..Vern
OOPS! Forgot code , see next Reply .
Hello & Thanks ,
In my code below , why is it the Html code
that the <div class="middle"> is specified BEFORE the
<aside class="left-sidebar"> and the <aside class="right-sidebar"> ?
Thanks..Vern
OOPS! Forgot code , see next Reply .
Short answer: the HTML source has middle before the asides because you (or the layout generator) wrote it that way on purpose — that is the DOM/source order the outliner reads. CSS (floats, negative margins, absolute positioning, etc.) then reflows and paints boxes in a different visual order; floats in particular are taken out of the normal flow and can make later source elements appear to the left/right of earlier ones. This is why the outliner reports the DOM order while the page looks different in the browser. (developer.mozilla.org)
Clarification on “outline” vs visual order: HTML5 document-outline tooling walks the DOM tree to build a semantic outline (source order). The official spec describes the outline algorithm as a DOM-tree walk — it’s not tied to painted positions — and, historically, browsers/AT have not relied on the outline algorithm for presentation, so tools that report an outline will show the source structure rather than the painted layout. (w3.org)
Accessibility and practical impact: screen readers and keyboard/tab navigation follow DOM/reading order, not what looks visually first; visual reordering (e.g., using Flexbox order) can therefore confuse assistive-tech users. MDN and accessibility testing groups warn about this disconnect and recommend testing any visual reorder for keyboard/screen-reader behavior. If you must match visual and reading order, consider the newer reading-flow features carefully and test. (developer.mozilla.org)
Practical tips (applies to your thread and complements and ): keep main content early in the source for SEO and faster perceived load; extract/inline critical above-the-fold CSS and load the rest asynchronously for better paint times. Use DevTools Elements to verify DOM order, toggle CSS rules to see what reorders the page, and test keyboard + a screen reader to confirm logical reading order. If using Flexbox to change visual order, a minimal example:
/* keep DOM: main, left, right */
.container { display: flex; }
.left { order: 1; width:250px; }
.main { order: 2; flex:1; }
.right { order: 3; width:250px; } For critical-CSS and rendering guidance see the web.dev guidance on extracting/ inlining critical CSS. (web.dev)
Jump to Post— rtrethewey 24The order of precedence within the cascade for CSS/stylesheet rules does not depend on the order in which those rules appear within your stylesheet. Search on "css precedence" and you'll find how this works.
Jump to Post— gentlemedia 803You can position elements with CSS wherever you want. The (html) source order of your elements does not has to be the same order visually. In your case the CSS
float,leftandmarginproperties positioned the main content and sidebars where you see them on the screen.It's usually …
Oops , forgot the code:
<!DOCTYPE html>
<!--
file:///C:/NotePad++/~~~Scratch-efile:///C:/NotePad++/~~~Scratch-etc/~Notepad_vmProjects/index_html5_liq_lcr_s2_m1000_hh75_fh50_eh_2.html -->
<html>
<head>
<meta charset="utf-8" />
<!--[if lt IE 9]><script src=""></script><![endif]-->
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style_html5_liq_lcr_s2_m1000_hh75_fh50_eh_2.css" rel="stylesheet">
<style>
/* Eric Meyer's CSS Reset */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* End of Eric Meyer's CSS Reset */
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
body {
font: 12px/18px Arial, sans-serif;
}
/* Begin of styles for the demo (you can remove them) */
a.expand {
width: 90px;
display: block;
margin: 10px 0 0;
}
a.expand:hover {
height: 500px;
}
/* End of of styles for the demo */
.wrapper {
min-width: 1000px;
max-width: 1000px;
margin: 0 auto;
}
/* Header
-----------------------------------------------------------------------------*/
.header {
height: 75px;
background: #FFE680;
}
/* Middle
-----------------------------------------------------------------------------*/
.middle {
border-left: 250px solid #B5E3FF;
border-right: 250px solid #FFACAA;
position: relative;
}
.middle:after {
display: table;
clear: both;
content: '';
}
.container {
width: 100%;
float: left;
overflow: hidden;
margin-right: -100%;
}
.content {
padding: 0 20px;
}
/* Left Sidebar
-----------------------------------------------------------------------------*/
.left-sidebar {
float: left;
width: 250px;
position: relative;
background: #B5E3FF;
left: -250px;
}
/* Right Sidebar
-----------------------------------------------------------------------------*/
.right-sidebar {
float: right;
margin-right: -250px;
width: 250px;
position: relative;
background: #FFACAA;
}
/* Footer
-----------------------------------------------------------------------------*/
.footer {
height: 50px;
background: #BFF08E;
}
</style>
</head>
<body>
<div class="wrapper">
<header class="header">
<strong>Header:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras tortor. Praesent dictum, libero ut tempus dictum, neque eros elementum mauris, quis mollis arcu velit ac diam. Etiam neque. Quisque nec turpis. Aliquam arcu nulla, dictum et, lacinia a, mollis in, ante. Sed eu felis in elit tempor venenatis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut ultricies porttitor purus. Proin non tellus at ligula fringilla tristique. Fusce vehicula quam. Curabitur vel tortor vitae pede imperdiet ultrices. Sed tortor.
</header><!-- .header-->
<div class="middle">
<div class="container">
<main class="content">
<strong>Content:</strong> Sed placerat accumsan ligula. Aliquam felis magna, congue quis, tempus eu, aliquam vitae, ante. Cras neque justo, ultrices at, rhoncus a, facilisis eget, nisl. Quisque vitae pede. Nam et augue. Sed a elit. Ut vel massa. Suspendisse nibh pede, ultrices vitae, ultrices nec, mollis non, nibh. In sit amet pede quis leo vulputate hendrerit. Cras laoreet leo et justo auctor condimentum. Integer id enim. Suspendisse egestas, dui ac egestas mollis, libero orci hendrerit lacus, et malesuada lorem neque ac libero. Morbi tempor pulvinar pede. Donec vel elit.
<a href="#" class="expand">Expand column</a> </main><!-- .content -->
</div><!-- .container-->
<aside class="left-sidebar">
<strong>Left Sidebar:</strong> Integer velit. Vestibulum nisi nunc, accumsan ut, vehicula sit amet, porta a, mi. Nam nisl tellus, placerat eget, posuere eget, egestas eget, dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In elementum urna a eros. Integer iaculis. Maecenas vel elit.
<a href="#" class="expand">Expand column</a> </aside><!-- .left-sidebar -->
<aside class="right-sidebar">
<strong>Right Sidebar:</strong> Integer velit. Vestibulum nisi nunc, accumsan ut, vehicula sit amet, porta a, mi. Nam nisl tellus, placerat eget, posuere eget, egestas eget, dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In elementum urna a eros. Integer iaculis. Maecenas vel elit.
<a href="#" class="expand">Expand column</a> </aside><!-- .right-sidebar -->
</div><!-- .middle-->
<footer class="footer">
<strong>Footer:</strong> Mus elit Morbi mus enim lacus at quis Nam eget morbi. Et semper urna urna non at cursus dolor vestibulum neque enim. Tellus interdum at laoreet laoreet lacinia lacinia sed Quisque justo quis. Hendrerit scelerisque lorem elit orci tempor tincidunt enim Phasellus dignissim tincidunt. Nunc vel et Sed nisl Vestibulum odio montes Aliquam volutpat pellentesque. Ut pede sagittis et quis nunc gravida porttitor ligula.
</footer><!-- .footer -->
</div><!-- .wrapper -->
</body>
</html>`
Thanks..vm
The order of precedence within the cascade for CSS/stylesheet rules does not depend on the order in which those rules appear within your stylesheet. Search on "css precedence" and you'll find how this works.
Sorry , guess i wasnt clear:
I am talking about the sequence of html5 code , not the css .
I would expect the html order(sequence) to be :
<aside class="left-sidebar">
<div class="middle">
<aside class="right-sidebar">
but it isnt, its :
<div class="middle">
<aside class="left-sidebar">
<aside class="right-sidebar">
Can someone explain why ?
I just added some <h3> code to hightlight the Outline: then handed it to : https://gsnedders.html5.org/outliner/
to Outline it for me ,
Which shows :
<div class="middle">
<aside class="left-sidebar">
<aside class="right-sidebar">
But magically , the browser displays :
<aside class="left-sidebar">
<div class="middle">
<aside class="right-sidebar">
<!DOCTYPE html>
<!--
file:///C:/NotePad++/~~~Scratch-efile:///C:/NotePad++/~~~Scratch-etc/~Notepad_vmProjects/index_html5_liq_lcr_s2_m1000_hh75_fh50_eh_2.html -->
<html>
<head>
<meta charset="utf-8" />
<!--[if lt IE 9]><script src=""></script><![endif]-->
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style_html5_liq_lcr_s2_m1000_hh75_fh50_eh_2.css" rel="stylesheet">
<style>
/* Eric Meyer's CSS Reset */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* End of Eric Meyer's CSS Reset */
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
body {
font: 12px/18px Arial, sans-serif;
}
/* Begin of styles for the demo (you can remove them) */
a.expand {
width: 90px;
display: block;
margin: 10px 0 0;
}
a.expand:hover {
height: 500px;
}
/* End of of styles for the demo */
.wrapper {
min-width: 1000px;
max-width: 1000px;
margin: 0 auto;
}
/* Header
-----------------------------------------------------------------------------*/
.header {
height: 75px;
background: #FFE680;
}
/* Middle
-----------------------------------------------------------------------------*/
.middle {
border-left: 250px solid #B5E3FF;
border-right: 250px solid #FFACAA;
position: relative;
}
.middle:after {
display: table;
clear: both;
content: '';
}
.container {
width: 100%;
float: left;
overflow: hidden;
margin-right: -100%;
}
.content {
padding: 0 20px;
}
/* Left Sidebar
-----------------------------------------------------------------------------*/
.left-sidebar {
float: left;
width: 250px;
position: relative;
background: #B5E3FF;
left: -250px;
}
/* Right Sidebar
-----------------------------------------------------------------------------*/
.right-sidebar {
float: right;
margin-right: -250px;
width: 250px;
position: relative;
background: #FFACAA;
}
/* Footer
-----------------------------------------------------------------------------*/
.footer {
height: 50px;
background: #BFF08E;
}
</style>
</head>
<body>
<div class="wrapper">
<header class="header">
<strong>Header:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras tortor. Praesent dictum, libero ut tempus dictum, neque eros elementum mauris, quis mollis arcu velit ac diam. Etiam neque. Quisque nec turpis. Aliquam arcu nulla, dictum et, lacinia a, mollis in, ante. Sed eu felis in elit tempor venenatis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut ultricies porttitor purus. Proin non tellus at ligula fringilla tristique. Fusce vehicula quam. Curabitur vel tortor vitae pede imperdiet ultrices. Sed tortor.
</header><!-- .header-->
<div class="middle">
<div class="container">
<main class="content">
<h3>middle.container<h3>
<strong>Content:</strong> Sed placerat accumsan ligula. Aliquam felis magna, congue quis, tempus eu, aliquam vitae, ante. Cras neque justo, ultrices at, rhoncus a, facilisis eget, nisl. Quisque vitae pede. Nam et augue. Sed a elit. Ut vel massa. Suspendisse nibh pede, ultrices vitae, ultrices nec, mollis non, nibh. In sit amet pede quis leo vulputate hendrerit. Cras laoreet leo et justo auctor condimentum. Integer id enim. Suspendisse egestas, dui ac egestas mollis, libero orci hendrerit lacus, et malesuada lorem neque ac libero. Morbi tempor pulvinar pede. Donec vel elit.
<a href="#" class="expand">Expand column</a> </main><!-- .content -->
</div><!-- .container-->
<aside class="left-sidebar">
<h3>Left Sidebar<h3>
<strong>Left Sidebar:</strong> Integer velit. Vestibulum nisi nunc, accumsan ut, vehicula sit amet, porta a, mi. Nam nisl tellus, placerat eget, posuere eget, egestas eget, dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In elementum urna a eros. Integer iaculis. Maecenas vel elit.
<a href="#" class="expand">Expand column</a> </aside><!-- .left-sidebar -->
<aside class="right-sidebar">
<h3>right-Sidebar<h3>
<strong>Right Sidebar:</strong> Integer velit. Vestibulum nisi nunc, accumsan ut, vehicula sit amet, porta a, mi. Nam nisl tellus, placerat eget, posuere eget, egestas eget, dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In elementum urna a eros. Integer iaculis. Maecenas vel elit.
<a href="#" class="expand">Expand column</a> </aside><!-- .right-sidebar -->
</div><!-- .middle-->
<footer class="footer">
<strong>Footer:</strong> Mus elit Morbi mus enim lacus at quis Nam eget morbi. Et semper urna urna non at cursus dolor vestibulum neque enim. Tellus interdum at laoreet laoreet lacinia lacinia sed Quisque justo quis. Hendrerit scelerisque lorem elit orci tempor tincidunt enim Phasellus dignissim tincidunt. Nunc vel et Sed nisl Vestibulum odio montes Aliquam volutpat pellentesque. Ut pede sagittis et quis nunc gravida porttitor ligula.
</footer><!-- .footer -->
</div><!-- .wrapper -->
</body>
</html>
Thanks..Vern
You can position elements with CSS wherever you want. The (html) source order of your elements does not has to be the same order visually. In your case the CSS float, left and margin properties positioned the main content and sidebars where you see them on the screen.
It's usually a good thing to have the main content div at the top in the source, because you want to make sure that search engine bots will scan it properly.
gentlemedia has the key
the sidebars are less important than the main content,
this code layout ensures::
that bots index the content in the desired order, and
display it in the desired layout
on a slow cell data plan, the important content displays before unimportant sidebars even download
== on-page optimising
please put all css in the external css file, shrink page size download css once
== on-page optimising
First oops I see is use of a div as a major section container. Try section element instead. Save div for really odd-ball stuff.
Need help sorting out tags? Try A Book Apart series title "HTML5 for Web Designers", by Jeremy Kieth and Rachel Andrew. The tag hierarchy was established by W3C to keep things organized.
Ref:
https://abookapart.com/products/html5-for-web-designers
[Only 10 bucks, excellent half hour read]
[Jeremy Kieth at Good Reads, original, pre HTML5]
http://mobilesoftware445.weebly.com/blog/download-free-a-book-apart-html5-for-web-designers-pdf
[Weebly at Media FIre, another free gander, this book's market integrity is really battered]
please put all css in the external css file, shrink page size download css once
I've been hearing lately that you want to inline (into the HTML head) a small amount of CSS used to render the above-the-fold content, for faster perceived performance. Slower connections don't have to download a huge external file with a lot of CSS properties for stuff not being used at the moment.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.