Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Can't center or add top margin to webpage

Aug 5, 2013 12:14PM PDT

I recently created a new webpage but I'm having problems trying to center it vertically. I'm really new to html and css so I was hoping someone might be able to explain to me in layman terms how to edit my html to either get my page to center vertically or at least how to add a top margin so the page isn't stuck right up against the top of the screen. I tried changing the top margin value from 0 to something else, but it didn't work. Here is my current html:

<html>
<head>
<title>Webpage Home 3</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (Webpage Home 3.psd) -->
<a href="http://website.com/portfolio.pdf">
<img src="images/index.jpg" width="1000" height="768" border="0" alt=""></a>
<!-- End ImageReady Slices -->
</body>
</html>


Any help with this would be much appreciated.

Discussion is locked

- Collapse -
Answer
(NT) Tell about your pdf woes too.
Aug 5, 2013 12:17PM PDT
- Collapse -
Answer
Re: margins
Aug 29, 2013 7:17PM PDT

Generally one uses tables (rather old-fashioned) and div's (somewhat newer-fashioned) to finetune the lay-out.
I think it's time to get studying some more html and css.

Kees

- Collapse -
Answer
One solution use css in body tag
Aug 31, 2013 8:40PM PDT

I use this template to align center and top margin of my site.

------- html -------
<body>
<div id="WholeWeb" >
your content
</div>
</body>

------- css -------------
body {
text-align: center;
margin: 0px;

}

.wholeweb {
margin:auto;
text-align: left;
width:960px;
top:0px;
}