DEV Community

Cover image for A history of web layout techniques: From Frames to WebAssembly
Andreas Bergström
Andreas Bergström

Posted on • Edited on

A history of web layout techniques: From Frames to WebAssembly

The world of web development has come a long way since its inception. In the early days, web developers faced various challenges while trying to create visually appealing, responsive, and interactive websites. Over the years, several layout techniques have emerged to make this task more manageable. In this blog post, we will take a trip down memory lane, exploring the evolution of HTML and CSS layout techniques that have shaped the web as we know it today, with code examples for each technique. Finally, we will discuss some speculation about the future of web development and the potential role of WebAssembly.

The Initial Web

In the early days of the web, in the mid-1990s, web developers were limited in the tools they had at their disposal. HTML was the primary markup language, and it provided a way to structure content on the page. CSS was not yet available, and styling was done using HTML attributes such as bgcolor, font, and align.

<body bgcolor="lightblue">
  <h1 align="center">Hello, World!</h1>
  <p><font size="3" color="red">This is an example paragraph.</font></p>
</body>
Enter fullscreen mode Exit fullscreen mode

The initial web was quite basic compared to what we have today. Web pages were predominantly static, with limited interactivity and visual appeal. Web browsers at the time had limited rendering capabilities, and web developers had to work within these constraints to create functional and visually appealing websites. Despite these limitations, the initial web played a crucial role in laying the foundation for the development of more advanced web technologies and design practices that we see today.

During this period, web developers primarily used HTML tags such as headings, paragraphs, lists, and images to structure their content. Hyperlinks were one of the most powerful features of the initial web, allowing users to navigate between pages and access a wealth of information with just a few clicks. HTML forms also played a vital role in enabling user input and interaction with web applications. However, since CSS was not yet available, developers had to rely on HTML attributes to style their pages, resulting in cluttered and difficult-to-maintain code.

Frames

Early webpage using frames

One of my first finished websites for a local business based on frames in the late 90's

Frames were introduced in HTML 4 as a way to divide a web page into multiple, scrollable sections. This technique allowed developers to create layouts with fixed headers, footers, or sidebars. However, frames came with a multitude of issues, such as poor accessibility, usability, and search engine optimization. As a result, frames fell out of favor and were eventually deprecated in HTML5.

<frameset cols="25%,75%">
  <frame src="sidebar.html" />
  <frame src="content.html" />
</frameset>
Enter fullscreen mode Exit fullscreen mode

Despite their drawbacks, frames did provide some valuable lessons to web developers at the time. By allowing the separation of a web page's sections, frames enabled developers to create more modular designs. This modularity proved beneficial when updating or maintaining parts of a website, as changes could be made to individual frames without affecting the entire page. The idea of compartmentalizing web content into distinct sections would later influence more advanced layout techniques, such as CSS Grid.

Another notable aspect of frames was their ability to load content from different sources, essentially embedding external content within a single webpage. This feature was an early attempt at creating more dynamic websites that could aggregate content from various locations. However, this approach led to several issues, including security concerns and difficulties in maintaining consistent user experiences across embedded content.

Table Design

Webpage using table layout

Another client project released in the mid 00's, using table design for layout.

During the late 1990s and early 2000s, web developers began using tables as a layout tool. Tables were initially intended for presenting tabular data, but they proved to be an effective way to create complex grid-based layouts. However, table-based layouts had their drawbacks, such as bloated code, slow loading times, and difficulties with responsive design.

<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" height="50">Header</td>
  </tr>
  <tr valign="top">
    <td width="20%">Sidebar</td>
    <td width="80%">Content</td>
  </tr>
  <tr>
    <td colspan="2" height="50">Footer</td>
  </tr>
</table>
Enter fullscreen mode Exit fullscreen mode

Table-based design relied on nesting tables within tables, using table rows and cells to create structure and align elements on a page. This approach often led to deeply nested and difficult-to-read code, making it challenging for developers to maintain and update their projects. Moreover, the excessive use of tables for layout purposes went against the principles of semantic HTML, where tags should convey meaning about the structure and purpose of the content, rather than its appearance.

Another significant issue with table-based design was its lack of responsiveness, as these layouts were not easily adaptable to varying screen sizes or resolutions. With the growing popularity of mobile devices, this limitation became a significant barrier to creating websites that provided a consistent user experience across different devices. As developers started to prioritize responsive design, the limitations of table-based layouts became even more apparent, leading to the adoption of newer CSS-based layout techniques. These techniques offered greater flexibility, cleaner code, and better performance, marking the beginning of a new era in web development, where responsive design and semantic HTML became central to the creation of visually appealing and accessible websites.

CSS Floats

Webpage using CSS floats for layout

A client project in the late 00's utilizing CSS floats for layout.

With the advent of CSS, developers could separate content from presentation, leading to cleaner and more maintainable code. CSS floats allowed developers to create multi-column layouts by positioning elements alongside each other. While floats solved many of the problems associated with table-based layouts, they still had their quirks and often required clearfix hacks to maintain a stable layout.

<!DOCTYPE html>
<html>
<head>
<style>
  .clearfix::after {
    content: "";
    display: table;
    clear: both;
  }
  .header, .footer {
    background-color: #f1f1f1;
    text-align: center;
    padding: 20px;
  }
  .column {
    float: left;
    padding: 10px;
  }
  .sidebar {
    width: 25%;
    background-color: #ccc;
  }
  .main {
    width: 75%;
  }
</style>
</head>
<body>
<div class="header">Header</div>
<div class="clearfix">
  <div class="column sidebar">Sidebar</div>
  <div class="column main">Main Content</div>
</div>
<div class="footer">Footer</div>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

CSS floats were initially introduced to allow text to wrap around images, but developers quickly realized their potential for creating more complex layouts. By applying the float property to an element, it would be taken out of the normal document flow and shifted to the left or right of its container. The other content within the container would then wrap around the floated element. By floating multiple elements in the same direction, developers could achieve a multi-column layout with relative ease.

However, the use of floats for layout purposes came with its own set of challenges. One of the most significant issues was the so-called "collapsing parent" problem. When all the child elements within a container were floated, the parent container's height would collapse to zero, causing subsequent elements in the document flow to move up and overlap with the floated content. To overcome this issue, developers had to employ clearfix hacks, such as inserting an empty element with the clear property set to both at the end of the container, or using the ::after pseudo-element with the clear property applied. Additionally, floats were often sensitive to the order of elements in the HTML, requiring developers to carefully structure their markup to ensure the desired layout. Despite these challenges, CSS floats were widely used for many years, providing a more flexible and maintainable alternative to table-based layouts until more advanced layout techniques became available.

Bootstrap and jQuery for Layouts

Bootstrap form on website

A typical Bootstrap-based login form, backoffice system for startup in mid 10's.

Around 2011, Bootstrap and jQuery emerged as game-changers in the world of web development. Bootstrap, an open-source CSS framework, provided a set of pre-designed CSS classes and components for creating responsive grid-based layouts. jQuery, a popular JavaScript library, made it easier to manipulate the DOM and create dynamic, interactive websites. Together, these tools streamlined the development process and made it simpler to build responsive, user-friendly websites.

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid">
  <div class="row">
    <div class="col-xs-12" style="background-color:#f1f1f1; text-align:center;">Header</div>
  </div>
  <div class="row">
    <div class="col-xs-3" style="background-color:#ccc;">Sidebar</div>
    <div class="col-xs-9">Main Content</div>
  </div>
  <div class="row">
    <div class="col-xs-12" style="background-color:#f1f1f1; text-align:center;">Footer</div>
  </div>
</div>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

One of the key drivers behind the adoption of libraries like Bootstrap and jQuery was the increasing demand for responsive web design. As the variety of devices used to access the internet grew, developers faced the challenge of creating websites that looked and functioned well on a wide range of screen sizes and resolutions. Bootstrap's responsive grid system and mobile-first design principles made it easier for developers to build websites that automatically adapted to the user's device. This helped ensure a consistent user experience across desktops, tablets, and smartphones, without the need for multiple versions of a website or extensive custom coding.

Another factor that contributed to the widespread use of Bootstrap and jQuery was the growing complexity of web applications. As web technologies advanced, users expected increasingly sophisticated features and user interfaces. This placed greater pressure on developers to deliver rich, interactive experiences without compromising on performance or maintainability. jQuery simplified many of the common tasks associated with DOM manipulation, event handling, and AJAX, allowing developers to write less code while achieving more advanced functionality. Meanwhile, Bootstrap offered a collection of reusable components, such as navigation bars, forms, and modals, that could be easily customized and integrated into a project. This enabled developers to focus on building unique features and functionality rather than reinventing the wheel for common UI elements. The combination of these libraries streamlined the development process, reduced the learning curve for newcomers to the field, and ultimately led to more efficient, maintainable, and user-friendly web applications.

Flexbox and Grid

As the web continued to evolve, the need for more powerful layout techniques became evident. Flexbox and Grid, introduced in CSS3, marked a significant shift in the way developers approached layout design. Flexbox made it easier to create flexible, one-dimensional layouts, while Grid introduced a two-dimensional layout system. Both techniques provided a level of control and flexibility previously unattainable, empowering developers to create complex, responsive layouts with ease.

<!DOCTYPE html>
<html>
<head>
<style>
  .wrapper {
    display: grid;
    grid-template-columns: 1fr 3fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "header header"
      "sidebar main"
      "footer footer";
  }
  .header, .footer {
    background-color: #f1f1f1;
    text-align: center;
    padding: 20px;
  }
  .sidebar {
    background-color: #ccc;
    grid-area: sidebar;
    padding: 10px;
  }
  .main {
    grid-area: main;
    padding: 10px;
  }
</style>
</head>
<body>

<div class="wrapper">
  <div class="header">Header</div>
  <div class="sidebar">Sidebar</div>
  <div class="main">Main Content</div>
  <div class="footer">Footer</div>
</div>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Flexbox and Grid brought a new level of sophistication to web layout design, offering developers more powerful tools to create modern, responsive designs. As the demand for complex, media-rich web applications grew, so did the limitations of CSS floats become more apparent. For over a decade, CSS floats had been the primary layout technique, but their shortcomings, such as the need for clearfix hacks and the difficulty in achieving equal height columns, became increasingly problematic.

The introduction of Flexbox addressed many of these pain points. With Flexbox, developers could easily create flexible, one-dimensional layouts that adapt to the available space in the container. This made it possible to build responsive, fluid designs that automatically adjusted based on the viewport size, without the need for complex calculations or media queries. Flexbox also made it easier to vertically align elements, a task that had been notoriously difficult with floats. Furthermore, the Flexbox model allowed for more intuitive ordering and arrangement of elements within a container, making it a more suitable choice for modern web development.

In contrast, Grid provided a two-dimensional layout system, allowing for precise control over both rows and columns. With Grid, developers could define explicit grid tracks, as well as leverage advanced features like overlapping grid items and template areas, which enabled more creative and intricate layout designs. Grid excelled in scenarios where a more structured, grid-based layout was desired, while Flexbox proved more versatile for simpler, one-dimensional layouts. Together, Flexbox and Grid offered web developers a comprehensive set of tools to create the dynamic, responsive layouts that modern web applications demanded, finally displacing CSS floats as the go-to layout techniques after more than a decade of dominance.

The Future: WebAssembly and CSS Houdini

As we look towards the future, it's worth considering how emerging technologies might shape the way we create web layouts. One such technology is WebAssembly, a binary instruction format designed as a portable target for the compilation of high-level languages like C, C++, and Rust, enabling deployment on the web for client and server applications.

WebAssembly has the potential to revolutionize web development by allowing developers to create custom layout engines tailored to their specific needs. These engines could potentially replace traditional HTML/CSS layouts in pure web applications, offering performance and flexibility improvements.

For instance, imagine creating a layout engine optimized for specific devices, screen resolutions, or input methods, without the constraints imposed by existing HTML/CSS layout techniques. This level of customization could lead to more efficient and performant web applications, ultimately improving the user experience.

While it's still early days for WebAssembly, its potential impact on web development cannot be overstated. As the technology matures and becomes more widely adopted, we may see a shift away from traditional HTML/CSS layouts towards more custom, high-performance solutions tailored to individual use cases.

CSS Houdini is another emerging technology that could significantly impact the future of CSS standards and web layouts. Houdini is a collection of APIs that allow developers to extend the capabilities of CSS and tap into the browser's rendering engine, enabling them to create custom CSS properties, values, and layout algorithms. This increased control over the rendering process can lead to more performant, efficient, and innovative web designs.

With CSS Houdini, developers can create unique, visually appealing layouts that break free from the limitations of traditional CSS techniques. This newfound freedom fosters creativity and encourages the development of novel layout solutions, tailored to specific use cases and needs. As Houdini gains more widespread adoption, we can expect to see an increase in the number of custom CSS implementations and a shift in the way designers and developers approach web layout creation. Combined with the potential of WebAssembly, these technologies have the potential to shape the future of web development in new and exciting ways.

The evolution of HTML and CSS layout techniques has been driven by the ever-changing needs of web developers and users alike. From the humble beginnings of the initial web, through the era of frames and table designs, to the present-day sophistication of Flexbox and Grid, the journey has been nothing short of remarkable. As we continue to push the boundaries of web development and explore new technologies like WebAssembly, it's an exciting time to be a part of this constantly evolving industry.

Top comments (1)

Collapse
 
fruntend profile image
fruntend

Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍