Is there a way to break on a hyphen instead of breaking on the last letter?

Is there a way to make the browser wrap on hyphens instead of cutting off the last letter on a line?

I haven't noticed any difference between word-break and word-wrap.

Check out this live example:

<div style="word-break:break-normal;font-size:14px;width:109px;">
    Members-Only Menu
</div>

Currently, it looks like this:

Members-Onl
y Menu

But I need it to look like this:

Members-
Only Menu

Any suggestions on how to achieve that?

Answer №1

Check out the CSS attributes for handling line breaks - word-wrap, word-break, and white-space, as well as the use of the <wbr/> tag.

Answer №2

If you want the words to only break at the hyphen, you can use the CSS property hyphens: manual. It's important to note that this property is not supported in Chrome, Android browser, or versions of IE prior to 10.

For additional information on this topic, check out this resource.

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

Connecting within a webpage without the use of the pound sign

I have a simple question as I am relatively new to programming, having only started about two weeks ago. I want to create a menu with three options: menu1, menu2, and menu3. My question is how can I create a link without using the hashtag (#)? For exampl ...

Having trouble vertically centering a div within a grid using bootstrap

How can I vertically center the card with the other content in the right div? https://i.sstatic.net/FSPmU.png This is my code: le="margin-bottom:100px"> I Agree With the terms and service Request Code <link href="https://stackp ...

Want to know more about the font-face onload method?

I'm currently working on a loading screen which not only performs an animation, but also generates multiple img objects in JavaScript. These images are linked to an onload method that counts their progress. The loading process is completed once the co ...

Customize the slide-in menu on your WordPress theme by adding jQuery and enhancing it with CSS animations

I'm attempting to create a sliding menu that appears when clicked and disappears when the close button is activated. Unfortunately, I can't seem to get it to slide out properly. jQuery(function($){ $('#menu-open').click(function ...

Adjust width when hovering or moving the mouse in and out

Apologies for the lack of a creative title... I'm sharing the following code snippet: .wrapper { display: flex; border: 1px solid red; padding: 10px; } .groups { display: flex; border: 2px solid blue; width: 70%; } .leftColumn { widt ...

When contenteditable divs are reloaded, the hidden content disappears

When it comes to editing text, I utilize contenteditable divs on my website. The height of the div dynamically grows as I make changes, causing all other elements below it to shift downwards - which is exactly what I want. Once I've finished editing, ...

How to Align Image and Overlay Div in Bootstrap 4

I'm trying to center an image and a div layer within a parent div, but I'm having trouble getting it to shift from the left side of the column. I've experimented with several methods, but nothing seems to work. Even using the margin auto tec ...

Creative Text Container CSS Styling

Check out this website for the container I want to replicate: container This is the specific textbox: Here's how mine currently appears: I analyzed their css file and examined their html source code. I isolated the section of html and css related t ...

Adaptable/Responsive Layout

Thank you for taking the time to look at this post. I am currently working on gaining experience with html, CSS, and JavaScript in hopes of entering the Front End Developer field. Today, I encountered a few issues while working on this adaptive design. He ...

Chrome is giving me trouble with the Select (dropdown) background image feature

Is it possible to set an image as the background for a select/drop-down menu? I've tried using the following CSS, which works in Firefox and IE but not in Chrome: #main .drop-down-loc { width:506px; height: 30px; border: none; background-color: Tr ...

div positioned on top of additional div elements

My HTML code consists of simple div tags <div class="left">Project Name: </div> <div class="right">should have a name</div> <div>Shouldn't this be on a new line?</div> These classes are defined in a stylesheet as ...

Combining left-aligned and centered elements within a grid using flexbox

Looking to create a fluid responsive grid layout using flexbox, without the need for media queries. The number of elements in the grid can vary and each item should have a fixed, equal width with left alignment. The entire group should have equal left and ...

Troubleshooting problem with aligning grid items at the center in React using

I've been facing a challenge in centering my elements group using the material ui grid system. Problem: There seems to be excess margin space on the extreme right. Code snippet: const renderProjects = projects.map(project => ( <Grid item ...

Tips for updating the color of table data when the value exceeds 0

I'm currently working on developing a transaction table that is intended to display debit values in red and credit values in green. However, I would like these colors to only be applied if the value in the table data is greater than 0 via JavaScript. ...

What sets bootstrap.css apart from bootstrap-responsive.css?

Can you explain the difference between bootstrap.css and bootstrap-responsive.css? I'm unsure which one is best for creating responsive websites. ...

Develop a versatile currency symbol mixin that can be used in various small text formats

I am currently working on a website where I need to display prices in multiple locations. To achieve this, I have created a sass mixin that is designed to add the desired currency symbol before the price with a smaller font-size. Below are examples of how ...

What is the method for using the "less than" operator in a CSS3 selector?

Suppose I have the following tag: <div id='testdiv' style='height:300px;'></div> What is the best way to create a CSS rule that targets the element: Select the tag with the id testdiv only if it has a style attribute se ...

Automatically adjust image size to fit the screen (without using JavaScript)

My art website features individual pages for each work, most of which are high-resolution photos. In order to optimize the viewing experience, I resize these images to fit the screen, ensuring they take up most of the available space. The resizing process ...

Certain computers are experiencing issues with Safari where the sprites background is not resizing correctly

Currently, I am working on a responsive CSS web design project that involves incorporating various sprites for different button states. After testing the website in Firefox, Opera, IE (compatible from IE8), Chrome, and Safari, I have ensured that everythi ...

What is the best way to utilize CSS to apply a background image with the cover property to a div instead of the body?

I'm working on a div called .cover-section and I want to give it a full background image that fills the viewport. I'm trying to use the cover css property to achieve this effect. So far, I've managed to make it work for the body of the page, ...