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 8675355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:55:47+00:00 2026-06-12T19:55:47+00:00

i am developing a mobile HTML5 page with css3, i am having the page

  • 0

i am developing a mobile HTML5 page with css3, i am having the page like below

<!DOCTYPE html>
<html>
    <head>
        <title>Starter page</title>
        <style>
            .float-right{float:right}
            .float-left{float:left}
            .clear{clear:both}
        </style>
    </head>

    <body>
    <div class="content" id="home">

            <div class=" ">
            <!--START: Div to be centered to page-->
                <div class="DivToBeCentered">
                    <div class="float-left">
                        <!--START: This paragraph content is dynamic from database, i want to center align the div with the class 
                                    DivToBeCentered with reference to its parent-->
                        <p class="">dynamic para 1 with background image</p>
                        <!--END: This paragraph content is dynamic from database, i want to center align the div with the class 
                                    DivToBeCentered with reference to its parent-->
                    </div>
                    <div class=" float-left">
                        <p class="">static para 2 without background image</p>
                    </div>
                    <div class="clear"></div>
                </div>
            <!--END: Div to be centered to page-->
            </div>

    </div>
    </body>
</html>

I want to horizontally center align the div with the class “DivToBeCentered” in the code above to its parent div. Inside that div there are two paragraph tags,for one paragraph tag content is dynamic, so its width may change while loading the page, how do i center align the that div with the class “DivToBeCentered” to its parent. it will be more helpful for me if you solve this, i got stuck in this issue for the day.Thanks in advance

  • 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-12T19:55:48+00:00Added an answer on June 12, 2026 at 7:55 pm

    simple solution will be display: inline-block; to the DivToBeCentered and text-align:center; to the outer div

    DEMO

    Css to be changed

    .outer {text-align:center;}
    .DivToBeCentered {display: inline-block;}
    
    
    
    
    <html>
        <head>
            <title>Starter page</title>
            <style>
                .float-right{float:right}
                .float-left{float:left}
                .clear{clear:both}
              .outer {text-align:center;}
              .DivToBeCentered {display:block-inline}
            </style>
        </head>
    
        <body>
        <div class="content" id="home">
    
                <div class="outer">
                <!--START: Div to be centered to page-->
                    <div class="DivToBeCentered">
                        <div class="float-left">
                            <!--START: This paragraph content is dynamic from database, i want to center align the div with the class 
                                        DivToBeCentered with reference to its parent-->
                            <p class="">dynamic para 1 with background image</p>
                            <!--END: This paragraph content is dynamic from database, i want to center align the div with the class 
                                        DivToBeCentered with reference to its parent-->
                        </div>
                        <div class=" float-left">
                            <p class="">static para 2 without background image</p>
                        </div>
                        <div class="clear"></div>
                    </div>
                <!--END: Div to be centered to page-->
                </div>
    
        </div>
        </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a mobile website in HTML/HTML5. This is NOT an iOS app but
I want to look into developing mobile applications using HTML5. I'm very new to
I'm developing a mobile app using ASP.Net MVC to generate HTML 5 pages. The
We are developing a hybrid mobile app (code is written in HTML and runs
I am new to phonegap.I am using jquery mobile with html5 for developing android
I am developing a mobile application with jquery mobile and html5. One Part of
=] Here's the thing: We're developing a webapplication with HTML5/CSS3/JavaScript/jQuery technologies. When I test
We are developing a website for low end mobile devices like Blackberry OS version
I'm developing a mobile website for smartphones and using jquery mobile. first test: http://pastehtml.com/view/bq51kpbmm.html
I am developing a mobile app using HTML5, Javascript, jQuery Mobile, and offline storage.

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.