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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:42:54+00:00 2026-05-31T13:42:54+00:00

Dear community members, I would like to position the text inside test in the

  • 0

Dear community members,

I would like to position the text inside test in the center of a div. The code would look like the following:

<div id="main" style="width: 960px;">
<form>
<label for="test">Testing everything:</label>
</form>

Now if I try the following section of code:

<label for="test" style="width: 100%; text-align:center;">Testing everything:</label>

It does not center the text inside my main layer. Do I need to put a layer arround the label tags making it:

<div style="width:100%; text-align:center;"><label for="test">Testing everything:</label></div>

What is the standard method to accomplish that?

Thank you for your responses!

  • 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-05-31T13:42:55+00:00Added an answer on May 31, 2026 at 1:42 pm

    Your problem is very simple : label is not a block-level tag, which means that you can’t give label elements a width. In other words, the width of a label element is the width of its content.

    In your case, that means that it doesn’t fill the entire width of your “test” div and then can’t be centered.

    To fix this, just add the following CSS property to your label :

    display: inline-block;

    This way, your label will be considered as a block for everything width (and height) related and your 100% width will be applied successfully, leading to a nicely centered text.

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

Sidebar

Related Questions

Dear community members, I have a small problem, which involves a text input field
Dear community members, I am actually a bit new to CSS, however I know
Dear members of the Stackoverflow community, We are developing a web application using the
Dear fellow programmers, I am working on my B&B's website www.bordemundo.com and would like
Dear Folk's i'm using the following code in order to send the bytes of
Dear friends,I want to extract text 平均3.6 星 from this code segment excerpted from
Dear community, it would be great if you could give me an advice on
Dear all, I have a select query that currently produces the following results: DoctorName
dear i have a datepicker inside my form. after i click the textfield, datepicker
dear all..i have this code: <script> var str=KD-R435MUN2D; var matches=str.match(/(EE|[EJU]).*(D)/i); if (matches) { var

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.