Baseline-source - CSS Property

baseline-source

Summary of characteristics of the baseline-source property

Quick description
Defines whether the vertical alignment of an element must be done relative to its first or last line of text.
Status
Standard
Usable for
HTML
Predefined values
auto | first | last
Percentages
Not applicable.
Initial value
auto
Inherited by default
No.
Discrète: during an animation, the baseline-source property passes from one value to another without transition.
Single: single value (no order).
W3C Module
CSS Inline Layout Module
Document status: WD (Working Draft)

Syntax diagram of baseline-source.

baseline-source - Syntax DiagramSyntax diagram of the baseline-source CSS property, which defines which line of text serves as the basis for alignment. auto auto first first last lastbaseline-source:;baseline-source:;
Syntax diagram of the baseline-source property.
The links in the diagram provide more details about the values.
Download the diagram in SVG.

Description of the baseline-source property.

The baseline-source property determines whether an inline element that may span multiple lines should be aligned by its first line or by its last line. This applies to elements displayed as inline-block, inline-flex, and inline-grid.

First line
Last line
First line

Last line

Elements inline-block aligned by their first line
.
First line
Last line
First line

Last line

Elements inline-block aligned by their last line
.

baseline-source is particularly important because inline elements do not all align in the same way by default. For example, inline-block elements align to their last line by default, while inline-flex elements align to their first line.

Values for baseline-source.

  • baseline-source: auto;

    Elements are aligned according to their default behavior, based on their type:

    • inline-block: aligned to their last line.
    • inline-flex: aligned to their first line.
    • inline-grid: aligned to their firsdt line.
    Element inline-block
    with 2 lines of text.
    Element inline-block
    with 3 lines
    of text.

    Element inline-flex
    with 2 lines of text.
    Element inline-flex
    with 3 lines
    of text.

    Element inline-grid
    with 2 lines of text.
    Element inline-grid
    with 3 lines
    of text.
  • baseline-source: first;

    The element aligns to its first line regardless of its display mode.

    Element inline-block
    with 2 lines of text.
    Element inline-block
    with 3 lines
    of text.

    Element inline-flex
    with 2 lines of text.
    Element inline-flex
    with 3 lines
    of text.

    Element inline-grid
    with 2 lines of text.
    Element inline-grid
    with 3 lines
    of text.
  • baseline-source: last;

    The element aligns to its last line regardless of its display mode.

    Element inline-block
    with 2 lines of text.
    Element inline-block
    with 3 lines
    of text.

    Element inline-flex
    with 2 lines of text.
    Element inline-flex
    with 3 lines
    of text.

    Element inline-grid
    with 2 lines of text.
    Element inline-grid
    with 3 lines
    of text.
  • baseline-source: initial; (auto) baseline-source: inherit; baseline-source: revert; baseline-source: revertLayer; baseline-source: unset;

    See the following pages for more details: initial, inherit, revert, revert-layer, unset.

Animation of the baseline-source property.

The animation of baseline-source is possible, of course in a discontinuous manner, that is to say that the property jumps abruptly from one value to another (no interpolation) since it involves only predefined values.

Below, we have three blocks whose display has been set to inline-block, and each of which contains a different number of lines.

First
Last
Only one
First
Second
Third
Fourth

Access the baseline-source property via a program

With Javascript, change the value of baseline-source.

In JavaScript, here's how to change the value of baseline-source. JavaScript supports a syntax using the standard CSS notation, kebab-case (hyphens to separate words), and another syntax using the camel-case notation (capital letters at the beginning of words).

Javascript
let el = document.getElementById('id'); el.style['baseline-source'] = 'first'; // or let el = document.getElementById('id'); el.style.baselineSource = 'first';

With Javascript, read the value of baseline-source.

This code retrieves the value of baseline-source when the property has been assigned directly to the element itself via its style attribute, rather than through a selector. There are two syntaxes as well.

Javascript
let el = document.getElementById('id'); let value = el.style['baseline-source']; // or let el = document.getElementById('id'); let value = el.style.baselineSource;

With Javascript, read the computed value of baseline-source.

The calculated value is either the result of the inheritance cascade or the initial value, i.e., auto in the case of baseline-source.

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('baseline-source');

With JQuery, change the value of baseline-source.

JQuery

$('#id').css('baseline-source', 'first');
// or
$('#id').css('baselineSource', 'first');

With JQuery, read the computed value of baseline-source.

JQuery
let value = $('#id').css('baseline-source');

Other code examples.

More examples of JavaScript and jQuery code can be found on the Javascript and CSS page.

Try it for yourself

The buttons below apply the entered value to the baseline-source property and then display the value as it was applied, or the calculated value. In the case of baseline-source, the result will be the same unless you enter an incorrect value.

Simulator.

baseline-source :
Parent : baseline
inline-block

Midline

Last line.
inline-flex
Midline
Last line

Browsers compatibility with baseline-source.

The baseline-source property is starting to gain widespread recognition (2026). It can be used, but please note that Safari   is not yet compatible, nor are most less-common browsers.

Column 1
Support for the property baseline-source, which defines whether an element should be aligned to its last line or its first line of text.
1
baseline-source
property
Estimated overall support.
76%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Edge

Safari

Firefox

Opéra

Safari sur IOS

Chrome

Chrome pour Androïd

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini

Historic of the baseline-source property.

  • CSS Inline Layout Module Level 3

    This module covers everything related to text block alignment, both within grid-based containers and for inline blocks (content within a flexbox or an inline-block). The vertical alignment properties, in particular, have been significantly enhanced.

    Regarding baseline-source. Building on the limited vertical alignment capabilities of CSS2, the baseline-source property has been added.
    WD
    December 18, 2014
    Working Draft.
    CR
    PR
    REC

See also, regarding the online dispositions.

The specification module named CSS Inline Layout Module defines aspects related to the layout of elements relative to the line, whether within a SVG object or a HTML document. The baseline-source property is described in this module, along with the following:

Properties:

alignment-baseline
Defines how an element is aligned vertically relative to its parent.
baseline-shift
Langue française
Set the offset, up or down, of the baseline of the text.
Baseline-source
Defines whether the vertical alignment of an element must be done relative to its first or last line of text.
dominant-baseline
Langue française
Specifies which baseline is used for vertical text alignment.
initial-letter
Langue française
Sets a drop cap: character size, how many lines it covers, etc.
initial-letter-wrap
Langue française
Defines how the text should wrap around drop caps, specifically following as closely as possible the shape of the drop cap character or not.
line-height
Langue française
Sets the height of lines of text.
text-box
Langue française
Allows the removal of spaces located before and/or after the lines of text.
text-box-edge
Langue française
Sets the metric for CJK texts.
text-box-trim
Langue française
Specifies how reducing the dimensions of a text box should be done to conform to text-box-edge (CJK languages).
vertical-align
Langue française