Favorites

CSS <baseline-position> Data Type

<baseline-position>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <baseline-position> data type is the keyword baseline, first baseline or last baseline, which aligns items by their text baselines.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <baseline-position> CSS data type represents the keywords used to align items by their text baselines rather than by their box edges. It is accepted by the box alignment properties, including align-items, align-self, align-content, justify-items and justify-self, as well as the place-items and place-self shorthands.

Baseline alignment is useful when neighbouring items contain text of different sizes. Aligning them to the top or centre makes the text look uneven, whereas aligning their baselines makes the text sit on one shared line, the way words of different sizes sit on the same line in a sentence. The keyword baseline on its own is the same as first baseline, which uses the baseline of the first line of text in each item. last baseline uses the baseline of the last line of text instead, which is handy for aligning the bottoms of cards or form rows with multi-line content.

Items that take part in baseline alignment form a baseline-sharing group. If an item has no text to produce a baseline, the browser synthesizes one from the item's box edges. When baseline alignment cannot be applied, the value falls back to start (for first baseline) or end (for last baseline).

Examples:

/* Price and label sit on the same text line */
.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

/* Align multi-line cards by the last line of text */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: last baseline;
}

/* One item opting into baseline alignment */
.badge {
  align-self: first baseline;
}

The <baseline-position> type works alongside the other alignment types, such as <content-position> and <self-position>, and can be useful in typographic layouts such as headings with icons, navigation bars and pricing tables.

Interactive Demo

Big
Two lines of text here
Small
Demo Code
HTML Code
<div class="demo-element">
	<div style="font-size: 28px">Big</div>
	<div>Two lines of text here</div>
	<div style="font-size: 14px">Small</div>
</div>
CSS Code
.demo-element > div {
	padding: 6px 8px;
	background: #4361ee;
	color: #fff;
}
.demo-element > div:nth-child(2) {
	width: 90px;
	background: #f72585;
	font-size: 13px;
}
.demo-element {
	display: flex;
	gap: 6px;
	width: 300px;
	height: 130px;
	padding: 6px;
	box-sizing: border-box;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
	align-items: baseline;
}

Syntax

<baseline-position> = [ first | last ]? && baseline

Values

  • baselineAligns the item using its first baseline. This is the same as first baseline.
  • first baselineAligns the first baseline of the item with the first baseline of the other items in its baseline-sharing group. The fallback alignment is start.
  • last baselineAligns the last baseline of the item with the last baseline of the other items in its baseline-sharing group. The fallback alignment is end.

Example

<div class="wrap">
<h1>CSS &lt;baseline-position&gt; examples</h1>

<h2>align-items: flex-start</h2>
<div class="row start">
<div class="item big">Big</div>
<div class="item small">small text</div>
<div class="item multi">Two lines of<br>wrapped text</div>
</div>

<h2>align-items: baseline (first baseline)</h2>
<div class="row first">
<div class="item big">Big</div>
<div class="item small">small text</div>
<div class="item multi">Two lines of<br>wrapped text</div>
</div>

<h2>align-items: last baseline</h2>
<div class="row last">
<div class="item big">Big</div>
<div class="item small">small text</div>
<div class="item multi">Two lines of<br>wrapped text</div>
</div>
</div>
/* Compare start, baseline and last baseline alignment */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f6f8fb;
  color: #0f172a;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

h2 {
  font-size: 14px;
  color: #475569;
  margin: 18px 0 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

.row {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  /* guide line drawn near the shared baseline */
  background-image: linear-gradient(#fecaca, #fecaca);
  background-size: 100% 1px;
  background-repeat: no-repeat;
}

.row.start { align-items: flex-start; }
.row.first { align-items: baseline; }
.row.last { align-items: last baseline; }

.item {
  padding: 8px 12px;
  border-radius: 8px;
  background: #e0f2fe;
  max-width: 180px;
}

.item.big { font-size: 34px; background: #ede9fe; }
.item.small { font-size: 13px; }
.item.multi { font-size: 16px; background: #dcfce7; }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS baseline-position data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.