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

Optimizing your webpack bundle by dynamically splitting directories with the SplitChunks plugin

In an attempt to organize my React code, which was created using create-react-app, I am utilizing the splitChunks plugin in the following manner: The current structure of my components (JSX) is as follows: services serviceA ...

Utilizing Flask to gather information from a leaflet map

I am currently working on creating a webpage using Flask. The webpage features a leaflet map where users can click to create a marker that opens a popup window with a link. The link's purpose is to open a new page displaying the longitude and latitude ...

Can I utilize a specific interface type within another interface?

Can I pass an object along with its interface to a React component? Here's a sample of the interface I'd like to incorporate: interface TableProps { ObjectProps: Interface (not functioning properly); objects: Array<ObjectProps>; } Is i ...

Inadequate handling of the react-router replace function causing issues

I am currently using an onEnter hook that calls the following function: function (nextState, replace) { var unsubscribe = firebase.auth().onAuthStateChanged(function (user) { if (!user) { console.log('attempting to access a se ...

What is the expected output format for htmlspecialchars?

When I try the following: echo (htmlspecialchars("andreá")); I expect to see So, assuming that if I do echo (htmlspecialchars_decode("andreá")); I would get andreá. However, instead of the expected result, I see Additionally, when I run echo ...

Strange Behavior of HTML5 Audio Elements

I'm currently in the process of designing a shop website with a nostalgic Windows98 theme. On the product's page, I want to include a preview of audio. Here is the CSS code that I have used for the HTML5 audio element: audio::-webkit-media-contr ...

HTML5 canvas game issue: background fails to load

I'm a beginner at designing games using HTML5 canvas. I've been following a tutorial on creating games in the style of Angry Birds from the 'pro html5 games' book. I've completed all the steps in the tutorial, but I'm facing a ...

Could not establish a connection with 'http://localhost:3001/user/signup' due to a breach of the Content Security Policy in a web application built with React and Node.js

Currently in the process of developing a signup page with React, utilizing Node JS for the Backend. Encountering an issue when attempting to call the signup api on the Backend as it results in the following error message: "api.js:31 Refused to connect to & ...

Can a pledge be honored at a precise moment?

I have implemented transitions on my web page. When clicked, everything fades out to an opacity of 0 over a duration of 1 second. Then, a new page is swapped in and everything fades back in to an opacity of 1 over another 1-second duration. The issue aris ...

Role="presentation" containing a <form> element within

<nav> <ul class="nav nav-pills pull-right"> <li role="presentation"> <form action="/logout" method="POST" id="logout-form"> <a href="#" onClick="document.getElementById('logout-form&ap ...

The configuration error is due to the absence of the current language in the complete array of languages supported by i18

I am currently using NextJS and i18next for my project. Below is the configuration file I am using: const NextI18Next = require('next-i18next').default; module.exports = new NextI18Next({ localePath: 'public/static/locales', brows ...

VueJS Components experiencing issues with displaying images

Recently, I delved into learning VueJS and successfully created a basic restaurant menu page all within a single file. Excited by my progress, I decided to refactor the project using vue-cli, but hit a snag with the images not displaying properly. The cur ...

Error in React Typescript hook: The function is not executable

Since transitioning the code from React JavaScript to React TypeScript, I have been encountering an issue. I had a simple hook that toggles state between on/off or true/false. I am struggling with this transition as the code used to work perfectly in Java ...

Associating the object key and value with distinct attributes within the component

person = {name: 'Alice', age: '19', weight: 52} I'm looking to display both the keys and values from the object in one label and input field respectively. I attempted using Object.entries, but couldn't figure out how to sepa ...

Error encountered when attempting to build Reactjs using the npm run command with

Issue Explanation I am working on a React project where running the command 'npm start' works fine. However, when I try to execute 'npm run build', I encounter the following error: verbose node v12.16.3 verbose npm v6.14.4 ...

What is the best way to collect and store data from various sources in an HTML interface to a Google Spreadsheet?

Currently, I have a spreadsheet with a button that is supposed to link to a function in my Google Apps Script called openInputDialog. The goal is for this button to open an HTML UI where users can input text into five fields. This input should then be adde ...

Retrieve the website address from a string of HTML code

I'm struggling to extract the URL from a given String that contains an HTTP response with an HREF tag. I've managed to identify the start of the links, but I need to stop the string as soon as the HREF tag ends. How can I accomplish this? public ...

Can you explain the functionality of the clean-up function in useEffect with firebase?

Recently, I came across a tutorial on creating a realtime chatroom using React and Firebase. I found the AuthContext file particularly interesting and I have a question about the useEffect part, specifically why the clean-up function is just unsub(). Can a ...

Typescript tutorial: Implementing a 'lambda function call' for external method

The Issue Just recently diving into Typescript, I discovered that lambda functions are utilized to adjust the value of this. However, I find myself stuck on how to pass my view model's this into a function that calls another method that hasn't b ...

Expanding Gridview Width within a Container in ASP.Net: A Step-by-Step Guide

https://i.stack.imgur.com/ZaJE7.jpg After viewing the image above, I am facing a challenge with stretching and fixing a gridview to contain the entire div where it is placed. The issue arises when the gridview adjusts automatically based on the content&ap ...