I have noticed that the baseline of a Span element has shifted after updating my Chrome browser to a version that begins with

Once I updated to chrome Version

108.0.5359.94 (Official Build) (64-bit)
from
107.0.5304.87 (Official Build) (64-bit)
, the behavior of the span element changed drastically. It shifted its baseline when multiple spans were stacked on top of each other.

Expected behavior: The span should expand upwards (v-107) rather than downwards (v-108).

In version 107.0.5304.87 of Chrome: https://i.sstatic.net/H7Wc7.png

In version 108.0.5359.94 of Chrome: https://i.sstatic.net/rG0ZL.png

When running the code, it produces one of the results shown in the above two images depending on your Chrome version.

<html>

<!-- Body content -->
        <div dir="auto" style="line-height: 2.5; text-align: left;">
            <!-- Span elements and styles -->
        </div>

</body>

</html>

Is there a way to revert to the old behavior in the new updated Google Chrome version?

Answer №1

The this CL update brought about a significant change, as noted in issue 885175. This change introduced the align-self: last baseline value according to the draft specifications.


Note: I recently discovered this new value and am still uncertain about its full implications. If any corrections are needed, feel free to provide them.


In Chrome's latest implementation, the default setting for align-self seems to have shifted to first baseline. While it's unclear what the previous behavior was or how other User Agents handle the auto value, it appears that the old behavior resembled last baseline, different from Chrome's current approach with first baseline.

To maintain consistency across browsers and ensure similar behavior in Chrome versions >= 108, it's recommended to explicitly set the align-self property of inner flex containers (like <mark> elements) to last baseline.

Referencing the following example demonstrates the fix:

.parent-flex {
  display: inline-flex;
  align-items: flex-end;
}
.column {
  display: flex;
  flex-direction: column-reverse;
}
/*
  For demonstration purposes, the fix is only applied when the input is checked.
  The same would be added to your .column rule or to OP's <mark> elements
*/
:checked ~ * .column {
  align-self: last baseline;
}
<label for=inp>Apply the fix</label><input type=checkbox id=inp><br><br>

<span>Inline</span>
<span class="parent-flex">
  <span class="column">
    <span>row</span>
    <span>row</span>
    <span>row</span>
  </span>
</span>

Below is an extended version of the above fix within OP's original code:

mark { align-self: last baseline }
        <div dir="auto" style="line-height: 2.5; text-align: left;">
                <span data-start_offset="0" data-end="28" style="white-space: break-spaces;">Lorem ipsum dolor sit amet, </span>
                <span>
                    <span style="display: inline-flex; align-items: flex-end; position: relative;">
                        <mark id="28_39_96d6a5ea-a48a-447e-9312-cac338d30c4a" data-start_offset="28" data-end="39" style="color: rgb(0, 0, 0); background: rgb(255, 255, 255); position: relative; padding: 0px; cursor: default; display: flex; flex-direction: column-reverse; opacity: 0.9; line-height: 1.5em;">consectetur <div style="position: absolute; background: rgba(255, 255, 255, 0.24); height: 23px; width: 100%; z-index: -1;"></div>
                            <div style="min-width: 88px; height: 23px; background: rgb(255, 0, 199); position: absolute; z-index: -2;"></div>
                            <span title="Noun" class="" style="display: flex; min-height: 1.2em;">
                                <span id="96d6a5ea-a48a-447e-9312-cac338d30c4a" class="renderLabel" style="background: rgb(255, 255, 255); color: rgb(255, 0, 199); max-width: 88px; min-width: 88px; margin-left: 0px; flex: 1 1 0%;">Noun</span>
                            </span>
                        </mark>
                    </span>
... (truncated for brevity)

Answer №2

<html><head></head><body>
        <div dir="auto" style="line-height: 2.5;text-align: left;display: flex;flex-wrap: wrap;">
    
                <span data-start_offset="0" data-end="28" style="white-space: break-spaces;align-self: flex-end;line-height: 1.5;">Lorem ipsum dolor sit amet, </span>
                <span style="
    align-self: flex-end;
">
                    <span style="display: inline-flex; align-items: flex-end; position: relative;">
                        <mark id="28_39_96d6a5ea-a48a-447e-9312-cac338d30c4a" data-start_offset="28" data-end="39" style="color: rgb(0, 0, 0);background: rgb(255, 255, 255);position: relative;padding: 0px;cursor: default;display: flex;flex-direction: column-reverse;opacity: 0.9;line-height: 1.5em;">consectetur <div style="position: absolute; background: rgba(255, 255, 255, 0.24); height: 23px; width: 100%; z-index: -1;"></div>
                            <div style="min-width: 88px;height: 23px;background: rgb(255, 0, 199);position: absolute;z-index: -2;"></div>
                            <span title="Noun" class="" style="display: flex; min-height: 1.2em;">
                                <span id="96d6a5ea-a48a-447e-9312-cac338d30c4a" class="renderLabel" style="background: rgb(255, 255, 255); color: rgb(255, 0, 199); max-width: 88px; min-width: 88px; margin-left: 0px; flex: 1 1 0%;">Noun</span>
                            </span>
                        </mark>
                    </span>
                </span>
        ...
        
            </div>


</body></html>

The modifications include:

  • display: flex; flex-wrap: wrap; added to the wrapping div
  • align-self: flex-end; applied to items that should stay at the bottom
  • line-height: 1.5em; set for proper alignment to the baseline of certain elements

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Pressing the escape key on the keyboard will act as a shortcut to go

Is there a way to use Javascript in a browser to make the escape key on the keyboard go back? For instance, when visiting this page and clicking the "Fullscreen" link, it would be great to simply press the escape key and return to the previous page. What ...

stacking order of floated and positioned elements

After researching on MDN and reading through this insightful blog post, it is suggested that in the absence of a z-index, positioned elements are supposed to stack above float elements when they overlap. However, upon closer examination, the example prov ...

Customize the background color of a particular select element within an array of dynamically created select elements

I've been experimenting with jQuery to dynamically adjust the background color of a select element based on the chosen option. The select elements are being generated using the following code: while ($qrow = $qquery->fetch(PDO::FETCH_ASSOC)) { ...

Can integer values be stored in localStorage similar to JavaScript objects and retrieved without requiring typecasting?

After setting an integer value to a localStorage item: localStorage.setItem('a', 1) and checking its data type: typeof(localStorage.a) "string" it shows as a string. I then typecast it to an int for my purposes: parseInt(localStorage.a) My ...

What is the process for incorporating themes into CSS?

At the moment, I have set up variables to manage colors for both light and dark themes (such as --light-background-color, --dark-background-color). Handling two themes is manageable with this approach, but it feels a bit labor-intensive. If more themes wer ...

Trouble persisting in loading PopperJS and Bootstrap through RequireJS, despite following the suggested PopperJS version

Struggling to load jquery, popperjs, and bootstrap (v4-beta) using requirejs, I'm consistently encountering this error in the console: Uncaught Error: Bootstrap dropdown require Popper.js (https://popper.js.org) at bootstrap.js:6 at bootstrap ...

Optimize your HTML with Meleze.web's ASP.NET MVC 3 Razor minification and compression features

I came across meleze.web on NuGet, which claims to remove extra white spaces in generated HTML results. However, after adding the necessary configuration to my web.config file and running the application, I have not seen any changes in the result. Are th ...

What is the process for adding a download link to my canvas once I have updated the image?

Is it possible to create a download link for an image that rotates when clicked, and then allows the user to download the updated image? Any help would be appreciated.////////////////////////////////////////////////////////////////////// <!DOCTYPE ht ...

Error copying cell width attribute when using border collapse

Currently, I am attempting to duplicate a table header by copying the tr HTML and then replicating the th widths. Unfortunately, this method is unsuccessful as the widths are displayed as (width minus W) pixels when border: 'Wpx' and border-colla ...

Implementing AJAX mysqli interaction in PHP following the MVC design pattern

Today I'm encountering yet another AJAX-related error. I am in the process of developing a user registration system using AJAX and PHP, following MVC architecture. Previously, I successfully built a login system without AJAX that functions flawlessl ...

Loop through a JSON object within the collection of another ng-repeat loop

I'm facing an issue with my ng-repeat loop where I iterate through a JSON and display it in a table. The problem is that when I try to iterate through a nested JSON value, it's treating it as a string. <tr ng-repeat="(key,value) in event. ...

Ways to delete specific data and insert a new row into a Jquery data table without disrupting the remaining rows

I have a dataset with 100 rows of information, and I need to remove specific data based on ID and add new rows for those IDs. I also want to be able to edit the existing rows based on their IDs. Below is the code snippet I am using: oCustomization : { ...

using sass to nest multiple classes

In an attempt to utilize nested classes with Sass, I am working on a styling code that displays a button on hover. Here is the structure of my SCSS: .item{ border-bottom: 1px dotted #ccc; text-indent: 50px; height: 81%; padding: 2px; text-transf ...

PHP time counting script

Can a countdown script be created using PHP? Websites like 4shared.com or megaupload.com utilize a similar script that starts counting from 20 seconds to 0. I am able to see how many seconds are left on the web page before I can click on the download but ...

Is there a way to adjust the placement of this AccordionDetails utilizing Material UI's Grid system?

Here is a sketch of what I am aiming for: https://i.sstatic.net/SFHSpm.png This is my implementation using Material UI's Accordion component. https://i.sstatic.net/JyhCym.png Below is the code snippet for the AccordionDetails section, which is whe ...

MTG Life counter. Display fluctuations in count

I am currently working on a fun project creating an MTG (Magic The Gathering) life tracker, even though the code is quite messy. Despite its flaws, it still gets the job done. Click here to view the MTG life tracker https://i.stack.imgur.com/Su17J.png ...

Obtain GPS coordinates (latitude/longitude) from a Google map by dropping a marker on the

Is there a straightforward script that can load a Google Map and, when clicked, display a marker that saves the latitude and longitude values to a variable? Does anyone know if there is an existing PHP solution for this functionality? Appreciate any help ...

"Looking to replace a character class pattern using regex in JavaScript? Here's how you can easily

I have a string: "\W\W\R\" My goal is to transform this string using regular expressions into: <span>W</span><span>W</span>\R This is the code I'm currently using: "\W\W\R".replace(/&b ...

HTML - Retain placeholder text while user inputs

My input is structured like this: <input value="My text" placeholder="Placeholder"> Typing in the input causes the placeholder text to disappear, which is expected. However, I am looking to keep the placeholder text visible as a background behind ...

Deliver the GWT module in JavaScript format

Currently, I am in need of the following: I need to create a GWT module that can be seamlessly incorporated into a GWT app without requiring recompilation - essentially a plug-and-play solution. This module should include a widget along with various cla ...