CSS Portal

:left CSS Pseudo Class

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The :left pseudo-class in CSS is a structural pseudo-class that targets elements that are considered “left-aligned” in a particular context. It is primarily used in conjunction with table cells, flexbox, or grid layouts where an element’s placement can be determined relative to its container or its siblings. This pseudo-class allows developers to apply specific styles to elements that occupy the leftmost position without needing to manually assign classes or IDs. While not as commonly supported or widely implemented as pseudo-classes like :first-child, :left can be useful in highly controlled layout scenarios.

One common scenario where :left may be used is in table structures. For instance, the first column of a table can be targeted using :left to apply a unique background color, text alignment, or padding, helping differentiate it from other columns. Similarly, in CSS grid or flex layouts, items that start at the leftmost position in a row can be styled using this pseudo-class, allowing for easier visual cues or spacing adjustments.

Developers often combine :left with other CSS properties to achieve layout or stylistic effects. Properties like text-align, margin, and padding are commonly adjusted when using :left to ensure proper spacing and alignment. It is important to note that :left does not alter the DOM structure; it merely selects elements based on their visual or logical position.

Here is a simple example using a table:

<table>
  <tr>
    <td>Left Column</td>
    <td>Right Column</td>
  </tr>
  <tr>
    <td>Left Column</td>
    <td>Right Column</td>
  </tr>
</table>
td:left {
  background-color: #e0f7fa;
  text-align: left;
  padding-left: 10px;
}

In this example, the :left pseudo-class targets all table cells that are in the leftmost position of their respective rows, giving them a distinct background and left padding. This approach simplifies styling patterns where a uniform look for the first column or left-aligned items is required.

The :left pseudo-class is part of a broader set of positional and structural pseudo-classes, which include :right, :first-child, and :last-child, each serving a similar purpose but targeting different positions or relationships within the DOM.

Syntax

:left {
  /* ... */
}

Example

<body>
<section class="content">
<h1>Chapter 1</h1>
<p>This is an example of content that will be printed.
When you view this in "Print Preview," the browser
calculates which pages are even (left) and which are odd (right).</p>

<div style="page-break-after: always;"></div>

<h1>Chapter 2</h1>
<p>This page should trigger the :left styling because
it is the second page in the sequence.</p>
</section>
</body>
/* General page setup */
@page {
size: A4;
margin: 2cm;
}

/* Specific styling for Left-hand (Even) pages */
@page :left {
margin-left: 5cm; /* Wider margin for the binding/gutter */
margin-right: 2cm;

/* You can also add content to page corners in some browsers */
@top-left {
content: "Page " counter(page);
}
}

/* Specific styling for Right-hand (Odd) pages */
@page :right {
margin-left: 2cm;
margin-right: 5cm;
}

/* Regular CSS for the screen/content */
body {
font-family: serif;
line-height: 1.6;
}

Browser Support

The following information will show you the current browser support for the CSS :left pseudo class. Hover over a browser icon to see the version that first introduced support for this CSS psuedo class.

This psuedo class is supported in some modern browsers, but not all.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 31st December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!