What's new

Centering my website on the screen with HTML code help


Messages
11
Likes
1
I made my website on my laptop with a pretty small screen. I just opened it up on a much wider screen and it's awkwardly shifted over on the left hand side. I want it so that the site itself is centered, but not necessarily the text, pictures, ect. The page has tables on it for organizational purposes. I've been looking all over Google for help, but every HTML code I've found hasn't helped. Any suggestions?
 

RTContent

Power User
Messages
472
Likes
180
Just add this to the top and bottom of the main html body.

<table><center>

</center></table>

Let me know how it works out for you. Also posting the html doc would be helpful too.
 

inkpad.t

Guru
Messages
1,015
Likes
823
This needs to be done using Div Tags and CSS.

Layout using tables is not done much now a days although this is another option but seen as tables for tabular data , not layout.

Depending on what your site is in most cases the whole site is wrapped within a container using div tags and css for alignment .

You can make the site width with a pixel or percentage rate fixed or fluid.

As long as the wrapper/container for your site is set to center align it will or should show this in the browser.
 

humbug

Member
Messages
8
Likes
0
The post above this one is only particular right. Simply wrap your whole markup in a div with a class like "wrapper". Then in you CSS simply put .wrapper { margin: 0 auto; width: YOURLAYOUTWIDTH; }. "YOURLAYOUTWIDTH" has of course to be replaced with the width of your layout in px.
 

inkpad.t

Guru
Messages
1,015
Likes
823
infomatrix... not sure what your asking .

The above css and html is for a site i am making, at this stage everything is centered and contain within a wrapper/container in css and html div tags.

You can use css and html to place images where ever you want them to appear on your site. it can get a bit complicated sometimes with different areas where you use images if you want them to partly overlay over another image, but again Like a said above i am no coder and you should consult one or ask in this forum if you want to know something specific .

Most of the sites i do are for friends who want something fairly basic. anything advance is done by another friend of mine . I just do the basic layout of the over all site.

Most things are through css3/html and html5, and div tags when it comes to layout...

You can position something, make it look how you want , the typography you want, what happens to something on a rollover image, padding, what color and so much more just through css3.

Check it out on the net and might find what your asking.
 

infomatrix

Member
Messages
19
Likes
2
yeah i was asking if your above method could be used in a more loosely, general way, and be used to center not just pages but other things like images , text and stuff...but i see its there would be more specific, better designated options for thinks like that...thank you though...
 

inkpad.t

Guru
Messages
1,015
Likes
823
Yes you can...

You can place div tags within div tags.

So 1 div would be your wrapper/container with a start and end div tag.

Within this set of divs you can place other div tags for anything you want including images. You then target ( for want of a better word ) the div with the CSS3 and make it appear where you want. just remember that any padding etc you did for the wrapper/container css will affect how you images would be placed.

CSS3 is really good and fairly moderate to learn depending on your learning curve that is, but once you get the hang of it it's plain sailing.

Check out on the net. would recd you try this site. http://www.w3schools.com/
 

Top