What is the best way to use CSS to hyphenate a capitalized word?

I have a single word that needs to be hyphenated, but the lang=en hyphenate: auto property does not work on capitalized words.

To address this, I utilized the slice function in JavaScript to split the word in half so that the second half, which requires hyphenation, is no longer considered capital.

However, this solution functions effectively on Chrome but encounters issues with Firefox.

Although German permits the hyphenation of uppercase letters, I prefer not to switch languages.

Here's a snippet of example code:

let word = 'Exceptional'

<div>
<span class='hyphenate'>
{word.slice(0,1)}
{word.slice(1)}
<span>
<div>


.hyphenate {
display: 'flex'
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}

In this code snippet, if the div size is insufficient, 'Exceptional' will automatically be hyphenated in all browsers except for Firefox.

Answer №1

In my opinion, the CSS attribute you should be using is "hyphens" instead of "hyphenate". Give this a shot:

.hyphenate {
display: flex;
hyphens: auto;
}

For better compatibility, consider adding these properties as well according to this reference:

.hyphenate {
display: flex;
hyphens: auto;
-webkit-hyphens: auto;
-ms-hyphens: auto;
}

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

Customizing Pie Legends in Echart Configuration

I am trying to find a way to present pie chart legends along with their values in a unique format. I have attached an image for reference. Despite my efforts, I haven't been able to figure out how to achieve this specific display. If you take a look a ...

Having trouble inserting a new row into the AngularJS table?

Having trouble adding a new row to the table in angularjs when clicking the add button. Here is the link to the Plunkr example -https://plnkr.co/edit/s7XAaG4JbvbTTxiZ0V2z?p=preview The HTML code snippet is as follows: <html> <head> <script ...

Stop Material-UI InputLabel from shifting to the top left corner of the Select element

I've been struggling to implement a true Placeholder functionality for the Material-UI Select component. It seems that using the placeholder prop on `<Select />` isn't working as expected, and I'm having issues with passing it to the i ...

Locating HTML snippets within a document

I am trying to extract all HTML <p>...</p> elements from a document. I have been attempting to use regular expressions (Regex) with the following pattern: Regex regex = new Regex(@"\<p\>([^\>]*)\</p\>" ...

Arrange containers into a tower?

Currently, I am exploring the concept of stacking boxes. While I have a solid grasp on how to stack them vertically from top to bottom, I find myself puzzled about how to stack them horizontally. Check out my vertical stacking method here See how I a ...

Exploring the contrast between materialize-css and material UI libraries

After exploring the home pages of materializecss and materialUI, I noticed that materializecss describes itself as a modern responsive front-end framework based on Material Design, while materialUI mentions React components that implement Google's Mat ...

Is it possible for a complete CSS ".class" to possess the specificity of '!important'? [closed]

It's quite challenging to determine the exact inquiry being made here. This question lacks clarity, precision, completeness, specificity, and is overly general or rhetorical, making it impossible to answer in its current state. To obtain assistance in ...

Guide on utilizing DotNet Core 5.0 authentication seamlessly with Next.js

Currently, I am working on a Next.js website with a dotnet core API connected to a SQL Server database. My main challenge lies in creating a page to add new users and integrating it with dotnet core identity. Initially, I tried using the NextAuth.js packag ...

What causes my divs to change position when using text <h1>?

When I have multiple divs grouped together inside another div, the placement of my h1 tag shifts downwards. How can I prevent this from happening and ensure that the text is added without any unwanted shifting? This issue only occurs when there are two o ...

I'm struggling to figure out why the CSS isn't working properly

i found this markup like shown here i am curious why it appears that lines 12 & 13 .notes:link span, .notes:visited span { ... seems to be functioning .comments span, background-position: -16px -16px; } .permalink:link span, .permalink:visited sp ...

Utilize Javascript to input text into a webform

I am working on creating a bot that simulates user input for the WattsApp web website. When I manually type a message into the website, it enables a button that allows me to send the message. However, when my script runs, it finds the input box, changes t ...

How can I turn off Angular Grid's virtualization feature, where Angular generates div elements for the grid based on height and width positions?

Currently, I am working with an Angular grid (ag-grid) that dynamically creates div elements in the DOM to display data as the user scrolls or views different sections. As part of my testing process using Selenium WebDriver, I need to retrieve this data fr ...

Having trouble deleting the value and deselecting the checkbox item?

Feeling a bit confused about a coding issue I'm facing. The problem lies in the categories listed in my database, which I fetched and used to create a post. Now, I'm attempting to edit that post. The categories are in checkbox format, where check ...

An effective method for targeting a specific button within a CSS file

I have multiple button tags in my code, but I need to style a specific one using CSS. How can I target this particular button and apply styles only to it while leaving the others unchanged? Do I need to assign the button to a variable and reference that va ...

Assistance needed with dynamically resizing a background image

Is there a way to automatically adjust the size of a background image for an element? For instance, I want my links in HTML to have a background image with slanted borders and rounded corners. Usually, you would set the width of the anchor element to fit t ...

The method of utilizing React with Redux to display component properties

I am currently trying to include my common component in my main.js file Successfully implemented this However, when attempting to print my Redux data values in the common component, I created a method called handleClickForRedux to handle this task. Even af ...

"Dynamically setting route paths in Next.js for a seamless navigation experience

During our work hours, We are faced with a specific folder structure: pages/user/login.js The goal is to relocate it to http://example.com/login while keeping the link tags and folder organization intact. We still need to use <Link href="/user/l ...

Anchor elements and other inline elements not triggering MouseLeave event

Take a look at this CodePen link, particularly in Chrome: https://codepen.io/pkroupoderov/pen/jdRowv Sometimes, the mouseLeave event doesn't trigger when a user quickly moves the mouse over multiple images. This results in some images still having t ...

Using CSS sprites to style text links

I've been attempting to incorporate an image with various icons for text links in an unordered list, but I can't seem to display just one icon with some space next to it for the text. The code I have so far is: http://jsfiddle.net/XyVtq/2/ This ...

Sorting and pagination functionality in Material UI Table

I've been attempting to implement sorting functionality for my table based on the material UI guidelines. Despite following the documentation, I'm facing an issue where upon clicking on the header, the sort order indicator appears, but the data d ...