Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: HTML code to center my website  (Read 50724 times)

0 Members and 1 Guest are viewing this topic.

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: HTML code to center my website
« Reply #15 on: August 25, 2008, 03:04:45 AM »
Whatever kind of website you are doing, it will still work. It think the problem is, somehow you have one setting to align to the right, and another to the centre.

Try this: Remove all style, alignment (etc.) tags from the main HTML tags, like instead of <div align="left" style="color:red">, just use <div>. You can fill them back in later, as we go along.

Now use this as a template:
Code: [Select]
<html>
<head>
  <title>Title of Website</title>
</head>

<body>
  <center>
    <div align="center">
      <!-- Put everything in here, like the way I said above -->
    </div>
  </center>
</body>
</html>



Let us know how it goes, but don't give up. ;D
« Last Edit: August 26, 2008, 08:28:42 AM by kpac »

soybean



    Genius
  • The first soybean ever to learn the computer.
  • Thanked: 469
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 10
Re: HTML code to center my website
« Reply #16 on: August 25, 2008, 11:01:53 AM »
kpac, perhaps one point of the OP's requirements needs clarification.  Let's say his page is 800 pixels wide, i.e. a fixed width.  He wants the page to display horizontally centered when the viewer is using a larger resolution display and, we'll assume, has their browser window maximized.  For example, see http://hosanna-lutheran.org/ 

The code I gave worked perfectly for me, and that's the code FrontPage 2000 gives you to center a page.

Your code will center content within/on a page but will not center a fixed-width page within a browser window.  You seem to be still missing that point.  The OP wants to center a fixed-width page within the browser window, not just center text within the page.  Look at the link I provided; it's an example. 

Here's basically how tables can be used to accomplish this.  Paste this into a Notepad file, save it as .html, and open it in your browser, with your brower window maximized with a display resolution greater than 800 pixels wide.  You'll see how it center the page within the browser window, not just the text on the page.

Code: [Select]
<html>
<head>
  <title>Title of Website</title>
</head>

<body>
<table width="100%"><tr><td align="center">
<table border="1" width="800"><tr><td align="center">

Paste a long string of text here, wider than 800 pixels. It must be wider than 800 pixels
for this demonstration.

</td></tr></table>
</td></tr></table>
</body>
</html>
« Last Edit: August 25, 2008, 10:59:23 PM by soybean »

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: HTML code to center my website
« Reply #17 on: August 26, 2008, 08:30:35 AM »
Your code will center content within/on a page but will not center a fixed-width page within a browser window.  You seem to be still missing that point.  The OP wants to center a fixed-width page within the browser window, not just center text within the page.  Look at the link I provided; it's an example. 

Sorry, not missing any point. Look at my website (under my avatar). Feel free to view the source, and/or look at the CSS.

san_crazy



    Intermediate

    Re: HTML code to center my website
    « Reply #18 on: September 12, 2008, 07:52:00 AM »
    probably, you will not be able to align your body at center using align attribute of body tag. you can rather put the code inside <table></table> tags and use its align attribute to center the web page.

    Code: [Select]
    <body>
    <table align="center">
        <tr>
           <td>
                    <!---  put your entire code here--->
           </td>
        </tr>
    </table>
    </body>

    zahid



      Starter

      Re: HTML code to center my website
      « Reply #19 on: November 28, 2008, 12:54:09 PM »
      Hi dear i am new user but i have some some tips about it

      1st

      you Draw Layer and use your code,
      just you check it



       <script language="JavaScript" type="text/JavaScript">
      <!--
      function MM_reloadPage(init) {  //reloads the window if Nav4 resized
        if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
          document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
        else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
      }
      MM_reloadPage(true);
      //-->
      </script>
      <div id="Layer1" style="position:absolute; left:210px; top:7px; width:921px; height:557px; z-index:1"> <html> <head> <body> <title>
        <div align="center">Vision of Gor | A players outlook</div>
      </title>
        <DIV style="LEFT: 11px; BACKGROUND-IMAGE: url(http://www.freewebs.com/visionofgor/Background.jpg);
      WIDTH: 800px; BACKGROUND-REPEAT: no-repeat; POSITION: absolute; TOP: 2px; HEIGHT: 550px">
          <div style="position:absolute; left:170; top:26;">
          <iframe src="http://www.visionofgor.com/updates.html"
      name="A" WIDTH="613" HEIGHT="92" frameborder="0" allowtransparency="true"></iframe>
        </div>
        <div style="position:absolute; left:169; top:247;">
          <iframe src="http://www.visionofgor.com/00.html"
      name="Main" WIDTH="614" HEIGHT="285" frameborder="0" allowtransparency="true"></iframe>
        </div>
        <DIV style="PADDING-RIGHT: 0px; OVERFLOW-Y: auto; PADDING-LEFT: 0px; SCROLLBAR-FACE-COLOR:
      #0000ff; FONT-SIZE: 8pt; Z-INDEX: 1; FILTER: chroma(color=#0000FF);
               LEFT: 0px; OVERFLOW-X: hidden; PADDING-BOTTOM: 0px;
               SCROLLBAR-HIGHLIGHT-COLOR: #0000ff;
      OVERFLOW: auto;
               WIDTH: 150px; SCROLLBAR-SHADOW-COLOR: #0000ff; SCROLLBAR-3DLIGHT-COLOR: #0000ff;
               SCROLLBAR-ARROW-COLOR: #A67D1B;
               PADDING-TOP: 10px;
      SCROLLBAR-TRACK-COLOR: #0000ff; FONT-FAMILY: Times New Roman; SCROLLBAR-DARKSHADOW-COLOR:
      #0000ff; SCROLLBAR-BASE-COLOR: #0000ff; POSITION: absolute;
               TOP: 266px;
               HEIGHT: 300px;
      TEXT-ALIGN: justify" allowTransparency> <font size=2>
          <p align=center> <font color="#000000"> <a href="http://www.visionofgor.com/00.html" target="Main"> <font color="#ffffff">
            Intro[/url]
      </font>

           

            <a href="http://www.visionofgor.com/truthfact.html" target="Main"> <font color="#ffffff">
            Fact -vs- Truth[/url]
      </font>

            <a href="http://www.visionofgor.com/bookvsaol.html" target="Main"> <font color="#ffffff">
            Book -vs- AOL[/url]
      </font>

           

            <a href="http://www.visionofgor.com/RPcreed.html" target="Main"> <font color="#ffffff">
            RPer's Creed[/url]
      </font>

           

            <a href="http://www.visionofgor.com/readercomments.html" target="Main"> <font color="#ffffff">
            Reader's Comments[/url]
      </font>

           

            <a href="http://www.visionofgor.com/readercomments.html" target="Main"> <font color="#ffffff">
            Banners[/url]
      </font>

           

            <a href="http://www.visionofgor.com/links.html" target="Main"> <font color="#FFffff">
            Links[/url]
      </font>

           

            <a href="http://www.meoag.com/VoGcontact.html" target="Main"> <font color="#FFffff">
            Contact[/url]
      </font> </font></DIV>
        <DIV></DIV>
      </DIV>
      </BODY></head></HTML>
      </div>

      Regards,
      Zahid From Pakistan

      tbartley21

      • Guest
      Re: what is the code to make the text fit?
      « Reply #20 on: December 29, 2009, 03:53:31 PM »
      I wanted to know what is the code to make the text fit?

      Quantos



        Guru
      • Veni, Vidi, Vici
      • Thanked: 170
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Guru
      • OS: Linux variant
      Re: what is the code to make the text fit?
      « Reply #21 on: December 29, 2009, 04:09:56 PM »
      I wanted to know what is the code to make the text fit?
      And don't hijack other threads, irregardless of how old they may be.
      Evil is an exact science.

      tbartley21

      • Guest
      Re: HTML code to center my website
      « Reply #22 on: December 29, 2009, 04:13:23 PM »
      Why don't you stop telling me what I should do? If you reply to my question please answer it unless I do not what to read your reply. So do you know the question or not?

      Quantos



        Guru
      • Veni, Vidi, Vici
      • Thanked: 170
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Guru
      • OS: Linux variant
      Re: HTML code to center my website
      « Reply #23 on: December 29, 2009, 04:14:20 PM »
      Why don't you stop telling me what I should do? If you reply to my question please answer it unless I do not what to read your reply. So do you know the question or not?
      Because you need to know how to follow the rules.
      Evil is an exact science.

      tbartley21

      • Guest
      Re: HTML code to center my website
      « Reply #24 on: December 29, 2009, 04:16:00 PM »
      Well excuse me I am new to computer hope give me a break already. So like I said stop be a smart and answer the question. If not do not reply back.

      Quantos



        Guru
      • Veni, Vidi, Vici
      • Thanked: 170
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Guru
      • OS: Linux variant
      Re: HTML code to center my website
      « Reply #25 on: December 29, 2009, 04:18:55 PM »
      Well excuse me I am new to computer hope give me a break already. So like I said stop be a smart and answer the question. If not do not reply back.

      No, I don't give anyone a break.  Follow the rules or get no help.
      Evil is an exact science.

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: HTML code to center my website
      « Reply #26 on: December 29, 2009, 04:22:51 PM »
      Start your own thread, and while your there, hey, you could maybe give some details about your issue, instead of vague semi-suggestive implied questions that make it impossible to answer your question in the first place.
      I was trying to dereference Null Pointers before it was cool.

      tbartley21

      • Guest
      Re: HTML code to center my website
      « Reply #27 on: December 29, 2009, 04:25:25 PM »
      I just want a question to my answer. All that lip is unnecessary.

      Allan

      • Moderator

      • Mastermind
      • Thanked: 1260
      • Experience: Guru
      • OS: Windows 10
      Re: HTML code to center my website
      « Reply #28 on: December 29, 2009, 04:28:08 PM »
      This guy is posting the same nonsense all over. Just ignore him.

      Quantos



        Guru
      • Veni, Vidi, Vici
      • Thanked: 170
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Guru
      • OS: Linux variant
      Re: HTML code to center my website
      « Reply #29 on: December 29, 2009, 04:28:19 PM »
      I just want a question to my answer. All that lip is unnecessary.
      I think you really have no concept as to how or why to follow the rules.  You really should learn fast though.
      Evil is an exact science.