Divs with a specified width are not formatting text correctly in IE7

IE7 seems to have trouble wrapping text in a div with a width narrower than the text itself, unlike other browsers which handle it better.

<div class="office-header-info">
<div class="local-office">District of Columbia</div>
</div>
.office-header-info {
  float: left;
}

.local-office {
  color: #893f22;
  width: 165px;
  text-align: center;
  font-size: 22px;
  font-weight: bold;
  margin-top: 17px;
  white-space: normal;
  line-height: 1.1;
}

In IE7, the phrase "District of Columbia" remains on one line, whereas in other browsers it displays as:

District of
Columbia

In this case, IE7 is not displaying the text correctly on two lines like it should. Adding overflow:hidden results in cutting off the text entirely.

Do you know why IE7 is having difficulty wrapping the text to two lines?

Answer №1

white-space: pre; /* CSS 2.0 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3.0 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP Printers */
word-wrap: break-word; /* IE 5+ */

Feel free to try that out.

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

Ways to prevent a <a href> element with a class linked to javascript from behaving like a block element

I am currently facing an issue with formatting an inline navigation. The last link, which is associated with a JavaScript class, is causing the entire link to become a block element instead of aligning inline with the rest of the links in the navigation. ...

How can the '+' symbol affect the function "url(" + imageUrl + ")"?

I was looking at some jQuery code on a website and came across a line that confused me. What exactly does the + sign and spaces do in "url(" + imageUrl + ")"? I am new to jQuery and JavaScript. <!DOCTYPE html> <html lang="en"> <he ...

Implementing a dynamic top navbar that transitions to the side on desktop with Bootstrap

I have been faced with the challenge of creating a responsive navigation bar that appears at the top on mobile devices and on the side on desktops. The issue arises when considering how to structure the rows and columns to achieve this. For mobile views, ...

Transforming a Java Array or Collection into a JSON array

After running my Java code, the returned Collection (ArrayList) produces JSON through JAXB that looks like: {"todo":[{"name":"CAMPBELL","sales":"3","time":"1331662363931"}, {"name":"FRESNO","sales":"2","time":"1331662363931"}]} However, I am wondering if ...

Can you show me a way to use jQuery to delete several href links using their IDs at once?

Currently facing a challenge with removing multiple href links that share the same ID. Here is a snippet of my code: $('.delblk').click(function(e) { e.preventDefault(); var id = $(this).attr('id').substr(7); ...

Trouble with font sizing in a single line

Here's an interesting problem I encountered: <ol><li> <span>01</span><h4>SOME TEXT</h4> </li></ol> #faq ol li h4 { padding-bottom: 16px; padding-top: 14px; padding-left: 16px; max ...

Adjust the size of the div to fit its content while maintaining the transition animation

I am aiming for the DIV height to automatically adjust to the text within it, while also maintaining a minimum height. However, when the user hovers their mouse over the DIV, I want the height to change smoothly without losing the transition effect. When ...

Confusion arises when using Materialize CSS for selecting elements

Currently, I am working on an app using Cordova. Within this project, I have incorporated jQuery Mobile's CSS and JS along with Materialize CSS and JS. However, I recently encountered an issue after integrating the Materialize files. Specifically, whe ...

What could be causing the unexpected white gap within my div element even though I've adjusted its dimensions to be minimal?

<div style=" height:0; width: 0 ; border: 1px solid black ; "> This code snippet displays a div element with a specified height, width, and border color. However, there seems to be an issue with the rendering as some st ...

How can I decrease the spacing between text within a button using Bootstrap?

Here is the code I am working with: <button class="btn btn-dark" style="margin: 0px 5px 10px 5px;background-color:#eeeeee" disabled> <h5 style="color:#000000"><i><b>1,39€</b></i></h5& ...

Parent element with 'overflow: hidden' in CSS is causing child styles to be cropped out

.util-truncate { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } a { text-decoration: none; } a:focus { box-shadow: 0 0 0 3px blue; text-decoration: underline; } a:focus-visible { outline: 0; } <div ...

Content for Bootstrap carousel items can be divided into two separate divs arranged horizontally

I'm currently working with a bootstrap carousel that displays images and text on each carousel item. However, I want the content of each carousel item to be displayed horizontally, rather than vertically as shown in the image below. Here is the curre ...

Add new information after modifying it

Is there a way to retrieve the updated values from the table product and insert them into the purchases table? My code successfully updates the data, but encounters issues when trying to insert into the purchases table. <?php $ID=$_GET["stocksid"]; ...

The buttons are off-center on the page when the screen width is below 1199px, they should be centered instead of aligned to the

Using Bootstrap 5, I've successfully created a layout with aligned rows of buttons at 1200px and above. However, an issue arises at the XL breakpoint (1199px) where the buttons align to the left of the container instead of being centered. You can vie ...

Troubleshooting image resolution issues in ASP web application (using C#)

I've been working on developing an asp web application that requires users to register details of a person, including uploading an image. The file name of the details/image are stored in a SQL database with the image filename saved in an NVARCHAR colu ...

Background image covering entire page is exclusive for the home/index page only

I'm facing an interesting dilemma.. I've built a single-page application with a layout that includes a header, footer, and uses ui-router to display views. Now, my challenge is to have a full-page background on the homepage (index.html) and a wh ...

Encountering a TokenMismatchException when using javascript x-editable in Laravel 5.3

Despite trying various solutions from different sources, such as SO, none of them were able to resolve the issue before marking it as duplicated. Currently, I am utilizing the x-editable plugin to save a new record through a store route. After submitting ...

Switching the html src to data-src causes the image to not be generated

After making the change from using src to data-src in the image tag, I noticed that the image is not visible in the browser. Even though src worked fine, changing it to data-src caused the image to disappear. import GooglePlayImages from '../../assets ...

PhantomJS encountered a TypeError when trying to access a non-existent object during the evaluation of 'document.getElementById()'

Recently, I delved into the world of PhantomJS and its ability to extract data from websites through JavaScript. This process is commonly referred to as web scraping. My goal was to retrieve the text content of an element by its ID. However, I encountered ...

Changing direction of arrow upon dropdown menu opening with JavaScript

I have developed a piece of code that enables users to click on a div in order to reveal a dropdown menu containing radio buttons. My goal is to make the arrows rotate 180 degrees when the dropdown menus are opened, and then return to their original positi ...