Imagine a traditional layout consisting of paragraphs grouped with a sidebar. However, there are two issues with this setup: first, the browser displays the sidebar (typically used for navigation) before the main content, causing problems for screen readers and text-based browsers. To address this accessibility concern, the sidebar should be positioned after the article. This complicates using the common float:right
technique, as absolute positioning can lead to further complications. The second issue is tied to the first; on narrower screens, I don't want the sidebar to sit alongside the text but rather appear below it.
Is there a way to achieve the same visual layout while swapping the positions of the two elements: #main
and #sidebar
?
#main {
width: 100%;
}
#sidebar {
width: 150px;
height: 200px;
background-color: #abc;
float: right;
}
<div id="sidebar"></div>
<div id="main">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy...</p>
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout...</p>
</div>