When using inline elements with <br /> inside an inline-block, it displays unpredictable behavior

  • Why does the code appear differently on Chrome and Firefox (Mac)?

  • What can be done to ensure consistent rendering on both browsers?

Chrome https://i.sstatic.net/6Epl1.png

Firefox https://i.sstatic.net/wzWtO.png

<p style="display:inline-block">some <span>te<br/>xt</span></p>

Answer №1

It appears that browsers handle whitespace in different ways, but adding white-space: pre; can resolve the issue.

white-space:pre With this property, sequences of whitespace are preserved and lines are only broken at newline characters or <br> elements.

<p style="display:inline-block;white-space:pre;">some <span>te<br/>xt</span></p>

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 update the image in a hover container

I am working on a project with HTML code and I am trying to create a hover effect for an image. I want the image to change when hovering anywhere on the box, not just on the image itself. I have tried adding multiple classes and ids, but the image only cha ...

Button choosing one "YES" and one "No" from options within a group

I attempted to develop a similar layout like this: The requirement is to only allow one "Yes" and one "No" option to be selected within each group, ensuring there are no consecutive selections in a row or column. https://i.sstatic.net/x1Td8.png I made a ...

What is the best way to set up my css in order to ensure that the height of a span aligns with the height of a nearby input field (specifically

Can someone help me fix this issue? https://i.sstatic.net/RyGML.png The span with the percent symbol is stretching to fit the input margin. How can I stop this from happening? I've already tried various CSS attributes but nothing seems to work in se ...

What is the best way to transfer a PHP string to JavaScript/JQuery for use in a function?

Within my PHP code, I have the following: $welcome = "Welcome!"; echo '<script type="text/javascript">addName();</script>'; Additionally, in my HTML/script portion: <a id="franBTN"></a> <script type="text/javascript ...

Cannot close the Bootstrap dropdown after selecting an option

I am encountering an issue with a dropdown list that has a select feature using Bootstrap 3.4.1. The problem is that the dropdown remains open after selection and does not close unless I click outside of the list. Here is the HTML code: <div id="c ...

Tips on styling HTML using a query value in string format

When using ASP.NET razor and SQL Server 2008 R2, I have a local variable declared in the following manner: var tsmMtd = db.QueryValue(" SELECT b.Name, SUM(subtotal) totalSUM FROM DR_TRANS a INNER JOIN Staff b ON a.Salesno = b.Staffno WHER ...

Can anyone provide guidance on extracting information from a database and saving it to an HTML file with Java?

Currently, I am working with a mysql database that consists of a table containing 5 columns. My next task involves retrieving the data from this specific table in the database and displaying it within an HTML file. This will require utilizing Java to stru ...

Is there a way to direct the embedded YouTube video on my HTML website to open in the YouTube application instead?

My website has embedded Youtube videos, but when viewing on a mobile browser they open in the default player. I want them to open in the Youtube application instead, as my videos are 360 degrees and do not work properly in the default browser player. ...

Is there a way to adjust the selected color of a TextField?

I'm currently working with the Material-UI React library and I am trying to customize the border color of a TextField when it is clicked or in focus. This is my attempt so far: const useStyles = makeStyles((theme) => ({ input: { borderWidth: ...

Delete the div if it exists following another div and place it within the main div

<div class="error"> <input type="text" name="email"> <div class="error-message">Please Enter Email</div> </div> <div class="i-icon-div">Lorem Ipsum</div> I am trying to identify the div with the class of i-icon-di ...

access an external link without disrupting automatic meta refresh

On my simple Teamspeak viewer site, I display the current users online. To auto-refresh the page every 60 seconds, I use this code: <meta http-equiv="refresh" content="60;url=index.html"> There is a button on the site that allows users to connect ...

Guide on adding dual horizontal scroll bars to a v-data-table (Vue / vuetify)

Currently, I am working on Vue / Vuetify and experimenting with the v-data-table component. While creating a table, I noticed that it has a horizontal scroll bar at the bottom. https://i.stack.imgur.com/noOzN.png My goal now is to implement two horizontal ...

Structure of Divs with Bootstrap

Looking to create a layout with two divs side by side like the image below: Example However, when the screen width increases, the layout changes to this: Current Here is the code: Is there anyone skilled in this area who can guide me through it? Your a ...

Learn how to dynamically change a class name with JavaScript to alter the color of a navbar icon

I have little experience with javascript, but I want to make a change to my navbar icon. Currently, my navbar has a black background with a white navbar icon. As I scroll the page, the navbar background changes to white and the font color changes to black. ...

What is the best way to create a complete margin separation between two unrelated elements?

Here is the code snippet I am currently working with: HTML <div class="container"> <div class="limit"> &nbsp; </div> <div class="dots"> &nbsp; </div> </div> CSS .container { background-colo ...

Issue with Bootstrap dropdown menu not showing up/functioning

I've spent the entire day trying to find a solution and experimenting with various methods, but I'm still unable to get it to work. The navbar-toggle (hamburger menu) shows up when the window is resized, but clicking on the button doesn't di ...

Discovering and choosing the appropriate course

I am facing a situation where I need to specifically select an element with the class .foo, but there are two anchor tags, both having the class .foo. However, I only want to select the one without the additional .bar class. How can I achieve this? <a ...

Sideways and alternative directional scrolling

I need assistance achieving a horizontal scroll with the main content centered in a div, while having links that move left and right. <div id="left"> Scrolls left </div> <div id="home"> Opens on this </div> <div id="right"> ...

The required attribute in HTML5 is not functioning as expected when used with an image input type

Hello, I am working on a form that includes various HTML controls and an image button. When this button is clicked, an AJAX call is made within a function. The server-side code executes successfully, but the required attribute does not seem to be working ...

Choosing and adding a div to another using the select method

Can someone assist me with this task? My goal is to dynamically append a div when selecting an option from a dropdown, and hide the div when the same option is selected again. Additionally, I want the name of the selected option to be displayed on the left ...