Jump to content
GoldSoft

Place div in the center screen

Recommended Posts

Here is the code u need .... <div style="text-align:center;" > write your text </div>

Which will place text in centre along top, but will not place DIV in centre horizontally and vertically.

Share this post


Link to post
Share on other sites

Hi dsonesuk, it is center in horizontally and about vertically means height of ur webpage .. my code is for center regardless of height .. if u know the height u can adjust as u wish ... for each query there is a separate code... so DIV center that too horizontally until know the height

Share this post


Link to post
Share on other sites

one more thing until define a width of a DIV the text inside the DIV is center if u want DIV center try this also

<div align="center" style="background-color:#FF0000;">

Put your code here..

</div>

Share this post


Link to post
Share on other sites

Title of topic "Place div in the centre screen", NOT text, the div being a block element stretches to the width available to it, only the text is centred when text-align: center; is used and is not vertically aligned in centre/middle because the height of div is determined by content, so it will always appear at the top of browser window screen instead of vertically centre/middle, which is what the poster wants for DIV element to automatically without the need to specify height place itself in middle of screen and NOT TEXT!

Share this post


Link to post
Share on other sites

Extra one more thing, check out link in post# 2, in it you will see DIV given a width/height, without knowing height/width of browser window centring itself horizontally and vertically.

Share this post


Link to post
Share on other sites

one more thing until define a width of a DIV the text inside the DIV is center if u want DIV center try this also<div align="center" style="background-color:#FF0000;">Put your code here..</div>

Again would ONLY CENTRE TEXT within any block element such as div, and will centre inline element such as anchor, but still not a DIV.

Share this post


Link to post
Share on other sites

our aim is "place div in the center screen" my solution is use <center> tag so that we can put DIV into center n this is possible with center tag that's it ...! Whatever we need solution. That's all.

Share this post


Link to post
Share on other sites

1) it does NOT! work anyway.

2) NO! the aim is to use current valid html, css to current standards.

3) http://w3schools.invisionzone.com/index.php?showtopic=48809 link which i have already provided, and pointed out to you before, has the solution or to be precise 3 solutions, all using valid html/css current standards. css 2 and css3.

Edited by dsonesuk

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...