Everything written below the CSS code

I am trying to create a layout where a line of text is aligned directly underneath another line of text.

Here is the HTML code:

<h4 class="support1">Number 123456</h4>
<h4 class="support2">Number 678910</h4>

This is the CSS code I used for styling:

.support1 { float:right;}
.support2 {float:right;}

If you want to see it in action, here is the Jsfiddle link:

http://jsfiddle.net/3Dtc4/

Answer №1

To achieve the desired effect, add clear:right to the .support2 class:

.support1, .support2 { float:right;}
.support2 { clear:right; }

Link to example

Answer №2

Do you really need the floating elements? A simpler solution could be to use block elements and align the text to the right:

http://jsfiddle.net/3Dtc4/9/

just by using text-align:right;

Answer №3

When using header elements, which are block level elements, they will automatically push subsequent elements down. To ensure both elements are aligned to the right and appear beneath each other, you can simply apply text-align: right;.

CSS

.support1, .support2 { 
  text-align: right;
} 

​ For example: http://jsfiddle.net/23U6Q/

Does this achieve the desired effect?

Answer №4

<h4 class="help1">Figure 54321</h4><br>
<h4 class="help2">Figure 109876</h4>

or

.help1 { float:right;}
.help2 {float:right; clear:right; }

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

Icon should be wrapped on two lines using the :before pseudo CSS element

My current scenario requires me to dynamically set the inner HTML of an element because it utilizes markdown: <div className='quote-copy' dangerouslySetInnerHTML={{ __html: body?.childMarkdownRemark?.html, }} /> Within t ...

What is the process for assigning a CSS class to a div element that is generated by react's render() function?

In React, I am encountering an issue where the css class I want to set on the div returned from render is being removed. This problem even persists when I try nesting another div inside the first one and setting the class on the enclosed div. Has anyone ...

Hovering over the top menu items in AngularJS will reveal dropdown submenus that will remain visible even when moving the cursor

I am facing an issue where my top menu has links that display a dropdown of additional menu items upon hovering. I have attempted to use onmouseover and onmouseleave events to control the visibility of the sub menu. However, I have encountered a problem ...

The glitch in the horizontal dropdown menu

Could you please review this Fiddle link: https://jsfiddle.net/wd9wj7oe/1/ The CODES are as follows: HTML <nav id="navigation"> <ul class="menu"> <li><a href="#">home</a></li ...

"Is it possible to create a single-page website with a unique logo for each div

Is it possible to have a unique logo on each section of my single-page website? Each section has its own div. Check out my website at . Thank you in advance! ...

Change the background color according to the user's input text

I want to create a text box where users can input color keywords like blue, lime, or black. When they click submit, I want the background color of the page to change accordingly. This is what I have so far: <label for="color">Color: </label> ...

What is the best method to remove the gap between my two horizontal div elements?

Is there a way to eliminate the small space between my two horizontal sections here? I've already attempted using margin: 0px; and padding: 0px; on the container, but it doesn't seem to be effective. Any assistance would be greatly appreciated! ...

The pattern() and onkeyup() functions are unable to function simultaneously

When trying to display a certain password pattern using regex while typing in the fields, I encountered a problem. The onkeyup() function works for checking if both passwords match, but it causes the pattern info box not to appear anymore. I'm curiou ...

"Encountering a PHP error while trying to print an HTML link

Hello, I am currently facing an issue with my PHP code. I am unable to resolve the error that is shown in the images below. I would like to make .$row[title] clickable, so that it can open a new PHP page. On this new page, I plan to add some descriptions ...

Enhancing the Appearance of NextJS React Data Tables

Task: I need to display a large DataTable in the UI with both horizontal and vertical scrolling capabilities Issue: Unable to enable scrolling on the X axis UI cuts off the first half of the table unless zoomed out UI becomes unusable Tried: Reviewed ...

Tips for aligning chart data alongside a chart that is compatible with various screen sizes

Positioning elements in CSS is presenting a new challenge for me, especially when it comes to creating a custom chart details section alongside my chart. Unfortunately, I am encountering issues with the display on different devices. While minor misalignmen ...

Is there a way to modify the background of a div when a specific field within my component is true and the div is being hovered over?

When I hover over a div, I want the background color to change. Additionally, I need the color choice to be based on an element within my component. <div *ngFor="let u of users;" [style:hover.background-color] = "u.selected ? 'red ...

Obtain a unique HTML ID dynamically with Selenium and VBA

I am currently working on automating a web form using Selenium and VBA. The form includes a search box that generates an autogenerated list when a value is entered. While I can successfully input a value into the search box and trigger the javascript to cr ...

Develop a custom WordPress meta box for managing the color scheme of individual posts and pages

Currently, I am in the process of learning how to create a custom WordPress meta box with a select tag for controlling the color scheme of individual posts/pages. My goal is to implement a system where I can use if statements to load an additional CSS file ...

Utilizing an image source for the Navbar logo

My Bootstrap v4.5.0 navbar is giving me trouble. I am trying to use a logo as the navbar brand, treating it like HTML text. However, I can't seem to replicate it successfully. Despite having other items in my navbar besides just the brand, the image i ...

Expanding the current tab on a horizontal list navigation in Internet Explorer 6 to fit the remaining space of the

I am facing a challenge with my top navigation in IE 6 on my website, which can be found at this link. The selected tab is expanding to fill the remaining space, causing issues. Any suggestions on how to resolve this without explicitly setting the width? ...

The applied style of NextUI Components may be inconsistent, appearing to not apply in certain instances even though it does work

I've hit a roadblock trying to solve this issue. While using NextUI, I've managed to successfully apply styles to some components like the navbar, indicating that I have correctly installed NextUI and configured Tailwind. However, I'm facing ...

CSS failing to accurately calculate width when children have percentage values assigned

This CSS quirk is quite interesting... An inline-block container will correctly calculate width when using units like px, vw, em, etc. But it behaves differently when using a percentage-based measurement. Percentage Example: https://i.sstatic.net/saI0M.j ...

Ensure that the modal remains open in the event of a triggered keydown action, preventing it from automatically closing

I am currently toggling the visibility of some modals by adjusting their CSS properties. I would like them to remain displayed until there is no user interaction for a period of 3 seconds. Is there a way to achieve this using JavaScript? Preferably with Vu ...

What could be the reason for the hover class not functioning properly in Tailwind?

Looking for some help with styling a button in Next.js using Tailwind. Specifically, I want the background color of the button to change when hovered over. I've been experimenting with code like this: <button className="rounded-full bg-gradie ...