Jump to content

Centered Text Inside A Div


dangercrow

Recommended Posts

You really should learn CSS, without it, your page won't look any better than pages did in the 90s.Considering that you say the <div> is on the left, I was supposing you were already using CSS to begin with.

Link to comment
Share on other sites

Not learning CSS is like not learning pizza. All you have left is bread.Try these two pages. One demonstrates text alignment. The other discusses different kinds of selectors you can use. They're all you need to solve this particular problem. Experiment with the try-it pages. Fun and easy.http://www.w3schools.com/css/tryit.asp?fil..._text-align_allhttp://www.w3schools.com/css/css_id_class.asp

Link to comment
Share on other sites

Ok, I have this:

<div style="text-align: center;" id="time">Server time:<br />05:33:58PM<br />on the<br />22/01/2010</div>

but the i need the div to act like a textbox, so the text is on the left, but it lines up with the lines above and below

Link to comment
Share on other sites

basically, my web page is locally hosted only atm, and is not on the web, but heres a pic:http://sites.google.com/site/dangercrow/untitled.gifwhat i want is the div on the left, but the text in it contained to be center aligned, as below:____________________________________|the form |submit |..................................||________|______|..................................||.Server time:..........................................||...12:00:00.............................................||......on the..............................................||...1/11/2011 ..........................................||.............................................................||.............................................................||___________________________________|so that the div is kind of contained, like a table.I tried using a table, but couldnt get it to work... any help appreciated

Link to comment
Share on other sites

To center the text in the div, use text-align:center on the div, as Ingolme posted before.The default position of a div is on the left. But you're having problems getting it on the left?Does it have a float property? Is it inside a container that centers it or has a lot of padding on the left side?Does the div itself have padding or margin that keeps its content from appearing on the left?I don't think you've mentioned yet what the div is doing that you don't want it to do. I know it's supposed to go on the left. Where is it now?

Link to comment
Share on other sites

If you haven't given the <div> a width, it will take the whole width of the page. Just add something like width: 200px; to the <div> and you'll see that it goes to the left while the text in it stays centered.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...