473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

display div tag content in center

vikas251074
198 100+
Here is my code. I want to display content in center of screen. But it is displaying in left side of screen. What to do for center alignment?

Thanks and regard,
Vikas

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <!--#include file="style.css"-->
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <title>IP Allocation</title>
  8. </head>
  9.  
  10. <body>
  11. <div id="myDiv" style="background-color:#CDCCBA; width:600px; height:600px;  ">
  12.   <table align="center">
  13.     <tr>
  14.       <th><font size="+1">Indian Oil Corporation Limited, Barauni Refinery</font></th>
  15.     </tr>
  16.   </table>
  17. </div>
  18. </body>
  19. </html>
  20.  
  21.  
Jun 6 '08 #1
10 6540
jeffstl
432 Expert 256MB
Easiest way I know of

Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2. body { 
  3. text-align: center; 
  4. </style>
  5.  
Jun 6 '08 #2
jeffstl
432 Expert 256MB
Just in case I tried this on your page, and it does work if you preview in IE anyway.....I have heard many rumblings though about how IE works one way with CSS while other browsers work right ;-)

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <style type="text/css">
  5. body { 
  6. text-align: center; 
  7. </style>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  11. <title>IP Allocation</title>
  12. </head>
  13.  
  14. <body>
  15. <div id="myDiv" align="center" style="background-color:#CDCCBA; width:600px; height:600px;  ">
  16.   <table align="center">
  17.     <tr>
  18.       <th><font size="+1">Indian Oil Corporation Limited, Barauni Refinery</font></th>
  19.     </tr>
  20.   </table>
  21. </div>
  22. </body>
  23. </html>
  24.  
Jun 6 '08 #3
vikas251074
198 100+
When set the top, left position in line no. 15 like this

Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" style="background-color:#CDCCBA; top:200; left:300 width:600px; height:500px;  ">
It does not have any effect,

Thanks and regards
Vikas
Jun 7 '08 #4
idsanjeev
241 100+
When set the top, left position in line no. 15 like this
Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" style="background-color:#CDCCBA; top:200; left:300 width:600px; height:500px;  ">
It does not have any effect,
Thanks and regards
Vikas
Hello vikas
you wants to set position of your div so you must have to write
style="position:absolute; ..................."
So please try inseted of your div tag
Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" style="position:absolute; top:200; left:300; width:600px; height:500px; background-color:#CCCC66 ">
Regards
Jha
Jun 7 '08 #5
vikas251074
198 100+
Still it is not working. I am surprised why it is not working. Such a simple code it is. What to do next?

Thanks and regards,
Vikas
Jun 7 '08 #6
idsanjeev
241 100+
can you attached your complete code for testing
regards
Jha
Jun 7 '08 #7
vikas251074
198 100+
Here is my complete code

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <!--#include file="style.css"-->
  4. <!--#include file="first.asp"-->
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  8. <title>IP Allocation</title>
  9. </head>
  10. </style>
  11. <body onLoad="document.myform.vlan_name.focus()">
  12. <form name="myform">
  13. <div id="myDiv" style="position:absolute; top:200; left:300; width:600px; height:500px; ">
  14.   <table align="center">
  15.     <tr height="50" valign="bottom">
  16.       <th align="center"><h2>Virtual Local Area Network (VLAN) Master</h2></th>
  17.     </tr>
  18.     <tr>
  19.       <table>
  20.         <tr>
  21.           <td align="right" style="width:125px ">VLAN Name :</td>
  22.           <td align="left"><input type="text" style="width:250px " name="vlan_name"/></td>
  23.         </tr>
  24.         <tr>
  25.           <td align="right" style="width:125px ">VLAN Range :</td>
  26.           <td align="left"><input type="text" style="width:100px " name="vlan_range"/></td>
  27.         </tr>
  28.         <tr>
  29.           <td align="right" style="width:125px ">VLAN First IP :</td>
  30.           <td align="left"><input type="text" style="width:100px " name="first_ip"/></td>
  31.         </tr>
  32.         <tr>
  33.           <td align="right" style="width:125px ">VLAN Last IP :</td>
  34.           <td align="left"><input type="text" style="width:100px " name="last_ip"/></td>
  35.         </tr>
  36.         <tr>
  37.           <td align="right" style="width:125px ">VLAN Subnet Mask :</td>
  38.           <td align="left"><input type="text" style="width:100px " name="subnet_mask"/></td>
  39.         </tr>
  40.         <tr>
  41.           <td align="right" style="width:125px ">Router :</td>
  42.           <td align="left"><input type="text" style="width:50px " name="router"/></td>
  43.         </tr>
  44.         <tr>
  45.           <td align="right" style="width:125px ">Switch :</td>
  46.           <td align="left"><input type="text" style="width:50px " name="switch"/></td>
  47.         </tr>
  48.         <tr>
  49.           <td align="right" style="width:125px ">Camera :</td>
  50.           <td align="left"><input type="text" style="width:50px " name="camera"/></td>
  51.         </tr>
  52.         <tr>
  53.           <td align="right" style="width:125px ">Printer :</td>
  54.           <td align="left"><input type="text" style="width:50px " name="printer"/></td>
  55.         </tr>
  56.         <tr>
  57.           <td align="right" style="width:125px ">Server :</td>
  58.           <td align="left"><input type="text" style="width:50px " name="server"/></td>
  59.         </tr>
  60.         <tr>
  61.           <td align="right" style="width:125px ">PC :</td>
  62.           <td align="left"><input type="text" style="width:50px " name="pc"/></td>
  63.         </tr>
  64.       </table>
  65.     </tr>
  66.   </table>
  67. </div>
  68. </form>
  69. </body>
  70. </html>
  71.  
  72.  
Jun 7 '08 #8
idsanjeev
241 100+
Here is my complete code
Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" style="position:absolute; top:200; left:300; width:600px; height:500px; ">
  2.  
please insert match it with your code
you got it working now
Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" style="position:absolute; top:200px; left:300px; width:600px; height:500px; ">
regards
jha
Jun 7 '08 #9
vikas251074
198 100+
Thanks I have solved this problem by using 'px' in line no. 13 with top and left attribute as follows

Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" style="position:absolute; top:109px; left:300px; width:600px; height:500px">
  2.  
  3.  
Sometimes it is very difficult to find simple problem like this.

Thanks and regards
Vikas
Jun 7 '08 #10
idsanjeev
241 100+
Sometimes it is very difficult to find simple problem like this.
Vikas
You are right anyway very glad you found it
nice programming
regards
jha
Jun 7 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sue | last post by:
Anyone have any ideas on why the code below will show up in a browser's sourcecode as an empty table, and is not visible? aspx: <headertemplate> <asp:Table ID="MyTable" runat="server" /> ...
3
by: N. Demos | last post by:
I have a single row table with fixed dimensioned cells nested inside a fixed dimensioned div, which has overflow: hidden. The div's dimensions are such that It should only display the first two...
3
by: andrewcw | last post by:
I have a simple winform with the following code. But although I can read back the info, the display fails to provide the text or the cell background color changes. private void ListViewBroke()...
2
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to...
21
by: Alan Silver | last post by:
Hello, The latest incarnation of my troubles can be seen at www.kidsinaction/fd3/x.html - both HTML and CSS validate. I have two problems with it... 1) If you view this in FF, quite often the...
3
by: Sjef Janssen | last post by:
I try to get a tabbed display work both in IE (6 and 7) and Firefox. The last does give a problem. What's going wrong here? I'm totally puzzled. <!doctype html PUBLIC "-//W3C//DTD XHTML 1.0...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
4
by: jeddiki | last post by:
Hi, I have been tinkering with this for a few hours now, but I just can not see why the left hand side column extends past my footer div. You can see what I mean here: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.