Is there a flaw in how Firefox handles text-overflow and inline-block?

It seems that according to the text-overflow specification, the ellipsis effect only applies to inline elements:

This property defines how content within an inline element is displayed when it overflows its container's boundaries in the inline direction.

However, while testing on Firefox (version 66.0.2 64-bit on macOS), it appears that the ellipsis is not being correctly applied to inline-block elements as specified. Instead, Firefox displays a whole inline-block as "…". See the code snippet below for a demonstration.

Is there a misinterpretation of the specifications or is this a bug in the Gecko browser?

My inquiry pertains to the following specifications:

.wrapper {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
  height: 40px;
  border: 1px solid lightgray;
  position: relative;
}

.wrapper div {
  display: inline-block;
  vertical-align: middle;
}

.wrapper img {
  vertical-align: middle;
}

.block {
  width: 40px;
  height: 40px;
  background: red;
}
<small>⚠️ Case 0 : ellipsis, preceding inline-block and contained text in inline-block</small>
<div class="wrapper">
  <div class="block"></div>
  <div>I'm not concerned by ellipsis for now.</div>
</div>

<font color="firefox, damn">❌ Case 1 : ellipsis, preceding inline-block and overflowing text in inline-block</font>
<div class="wrapper">
  <div class="block"></div>
  <div>I'm a text so long I'll overflow for sure, cause there is no space for me in this world, I'm doomed and you know it well. Why would you even wrap me in a div? A div? Do you hate me?</div>
</div>

<small>✅ Case 2 : ellipsis, no preceding block and overflowing text in inline-block</small>
<div class="wrapper">
  <div>I'm a text so long I'll overflow for sure, cause there is no space for me in this world, I'm doomed and you know it well. Why would you even wrap me in a div? A div? Do you hate me?</div>
</div>


<small>✅ Case 3 : ellipsis, no preceding block and overflowing text in a span (inlined by default)</small>
<div class="wrapper">
  <img src="https://placekitten.com/40/40">
  <span>I'm a text so long I'll overflow for sure, cause there is no space for me in this world, I'm doomed and you know it well. Why would you even wrap me in a div? A div? Do you hate me?</span>
</div>

<small>✅ Case 4 : ellipsis, span all over the place and overflowing second text</small>
<div class="wrapper">
  <span>I'm a first text.</span>
  <span>I'm a text so long I'll overflow for sure, cause there is no space for me in this world, I'm doomed and you know it well. Why would you even wrap me in a div? A div? Do you hate me?</span>
</div>

Answer №1

The behavior of Firefox appears to be optimal, closely followed by Chrome V75, and is consistent with the specific guidelines outlined in this section of the specification:

According to the specifications for ellipsis value, implementations should hide characters and atomic inline-level elements at the end edge of the line if necessary to accommodate the ellipsis. The ellipsis should be placed directly next to the end edge of the remaining inline content. It is important to note that the first character or atomic inline-level element on a line should be clipped rather than replaced with an ellipsis.

Therefore, the child divs within the wrapper are set to display:inline-block, making them considered as atomic inline-level boxes. If there is a preceding div, the long text is not contained within the first atomic inline-level element, allowing it to be ellipsed as required by the paragraph.

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

Tips on adjusting section height as window size changes?

Working on a website that is structured into sections. Initially, all links are aligned perfectly upon load. However, resizing the window causes misalignment issues. Check out my progress at: karenrubkiewicz.com/karenportfolio1 Appreciate any help! CSS: ...

If the desktop website is zoomed in beyond 150%, it will automatically switch to mobile responsive mode

Whenever the desktop website is zoomed above 150%, it automatically switches to mobile responsive mode. Is there a way to disable this feature? You can find the website in question here: Give it a try by zooming to 150 percent and see for yourself. Appr ...

React's Material-UI AppBar is failing to register click events

I'm experimenting with React, incorporating the AppBar and Drawer components from v0 Material-UI as functional components. I've defined the handleDrawerClick function within the class and passed it as a prop to be used as a click event in the fun ...

Error in identifying child element using class name

I need help accessing the element with the class "hs-input" within this structure: <div class = "hbspt-form".......> <form ....class="hs-form stacked"> <div class = "hs_firstname field hs-form-field"...> <div class = ...

The responsiveness of Angular Material appears to be limited when tested in Chrome's debug mode for different devices

I have come across a peculiar issue. Within my HTML file, I have defined two attributes: Hide me on small devices Hide me on larger than small devices When I resize the window, the attributes work as intended. However, when I enter device debug mode ( ...

I am having trouble getting bootstrap-icons to work in my Angular project and I'm eager to figure it out

I am having trouble incorporating bootstrap-icons into my angular project. Despite running the npm i bootstrap-icons command, I am unable to successfully add icons using icon fonts on my webpage. As a temporary solution, I have added the bootstrap icon CD ...

Utilizing a JavaScript class method through the onchange attribute triggering

I am facing an issue with a simple class that I have created. I can instantiate it and call the init function without any problems, but I am unable to call another method from the onchange attribute. Below is the code for the class: var ScheduleViewer = ...

Understanding the relationship between controller and view in AngularJS is crucial for building dynamic

My AngularJS script with MVC architecture is causing some issues. I suspect that there might be errors in the connection between the model, view, and controller layers. JS: var myApp = angular.module("myApp", []); //App.js myApp.controller('MainCon ...

Creating a Select component in React without relying on the Material-UI library involves customizing a dropdown

Is there a way to achieve a material UI style Select component without using the material UI library in my project? I'm interested in moving the label to the top left corner when the Select is focused. export default function App({...props}) { retu ...

Injecting external HTML into a Razor view with Html.Raw is causing the page's HTML to display incorrectly

I have a separate external HTML file, which serves as the body of an email. This HTML file contains all necessary tags and elements for a complete HTML structure. I am trying to display this email content inside a Bootstrap modal. <div class="moda ...

Is it possible to update the value of an element using JavaScript?

My goal is to manipulate the content of a specific element on a third-party web page using a JavaScript Add-on in order to display a clickable hyperlink. I have already identified the link that I want to interact with on the page, and I believe document.g ...

Remove interactive data tables from the onclick event

I have a dynamically rendered DataTable from https://datatables.net. I implemented an on-click event for the rows based on this tutorial: https://datatables.net/examples/advanced_init/events_live.html In the row, there is a select box that I excluded by ...

mobile-exclusive wordpress text area problem

There seems to be a padding issue that is only affecting mobile devices. https://i.stack.imgur.com/2Tbuc.png The cause of this problem has been somewhat identified, but the solution isn't clear without impacting the preview on computers. Here is th ...

CSS techniques for arranging images with varying sizes into a tiled layout

I have a collection of images that I want to arrange in a tiled layout, similar to the one shown in this image. These images consist of 3 photos with identical width and height, except for one which is larger and should occupy double the space compared to ...

Tips for choosing and deselecting data using jQuery

Is there a way to toggle the selection of data in my code? Currently, when I click on the data it gets selected and a tick image appears. However, I want it so that when I click again on the same data, the tick will disappear. How can I achieve this func ...

Is there a way to determine whether a mouse-down event took place on the scroll-bar or elsewhere within the element?

Looking for a solution with my HTML div acting as a canvas containing various objects. The issue lies in the fact that when attempting to draw a selection rectangle by dragging with the mouse, if scroll bars appear due to the large size of the canvas, scr ...

Switching from HTML to PHP programming

Trying to build a website from scratch and incorporate a form has been challenging. My goal is for the Submit button to send an email without launching any email program, but I'm facing redirection issues. Despite searching on Google for solutions, I ...

"Trouble with jQuery: Selecting an image to change isn't

Can someone help me figure out why my simple image change on a dropdown isn't working correctly? You can find the code on this Jsfiddle. Thank you for any assistance! $("#display_avatar").change(function(){ $("img[name=preview]").attr("src", $( ...

Unable to retrieve HTML content through a Node.js server

I created a HTML webpage that includes .css, images and JavaScript files. However, when I start my node server using the command below: app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); The webp ...

Tips for expanding a flex-grow element to fill the area of a concealed flex item

I am looking to create a window that can be divided into two or three areas based on the state of a checkbox. When the box is checked, I want the second area to be hidden and the first area to expand to fill the additional space. My layout works perfectly ...