Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8818125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:01:25+00:00 2026-06-14T05:01:25+00:00

Having a div and a h1 inside a section, how do i float the

  • 0

Having a div and a h1 inside a section, how do i float the div in the top right corner without overlapping the text of the header ?

The HTML code is the following:

<section>
  <h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1>
  <div><button>button</button></div>
</section>
  • I tried an absolute position relative to the parent but the text is overlapped, http://jsfiddle.net/FnpS8/2/

    div overlapping text

Using this CSS code:

section { position: relative; }
h1  { display: inline; }
div {
    position: absolute;
    top: 0;
    right: 0;
}
  • I tried floating the div to the right but it doesn’t remain in the top right corner, http://jsfiddle.net/P6xCw/2/

    div floated to the right

Using this CSS code:

h1  { display: inline; }
div { float: right;    }

​

I know there is a lot of similar questions but I couldn’t find one solving this case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:01:26+00:00Added an answer on June 14, 2026 at 5:01 am

    If you can change the order of the elements, floating will work.

    section {
      position: relative;
      width: 50%;
      border: 1px solid;
    }
    h1 {
      display: inline;
    }
    div {
      float: right;
    }
    <section>
      <div>
        <button>button</button>
      </div>
    
      <h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1>
    </section>

    ​By placing the div before the h1 and floating it to the right, you get the desired effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble left aligning a related links div inside a block of text,
I'm having a problem with dragging a div inside an other div element. HTML
I have a div having a css class MyClass. Inside this div, I can
I have a list of div with each div having a image inside. The
I have div having class name .modalPopup inside the div I have multiple table
I have a div inside an li as part of a top navigation for
I'm having an image inside a div. I want to show tooltip1 on mouseover
I'm having problems with the content loaded with AJAX inside a DIV. I need
I am having a problem with a block of my code, this section creates
anyone have some tips on how to make text inside a div scroll horizontally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.