Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a Margins setting in CSS? 1

Status
Not open for further replies.

Mike555

Technical User
Joined
Feb 21, 2003
Messages
1,200
Location
US
Is there a setting I can apply to a CSS so that the 'page setup' of each web page has specified margins?

For example - If I want each web page to have left and right margins of .25.

Thanks.

--
Mike
 
If you're talking about PRINTER margins, then there's not clear-cut way to set printer margins using CSS - this is a user setting.

If, however, you're not talking about printer margins, you can do something like the following:

Code:
<style type="text/css" media="print">
    body {
        margin-left: 25px;
        margin-right: 25px;
    }
</style>

This will not add a margin to the content when you're viewing it on-screen, but will add a margin of 25px to the left and right when you're printing the page.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Whoops, that paragraph shouldn't be in the code block :)

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
That code belongs in the CSS correct? Thanks.

--
Mike
 
This should go in the head, yes:

Code:
CODE
<style type="text/css" media="print">
    body {
        margin-left: 25px;
        margin-right: 25px;
    }
</style>

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Perfect - Thanks much

--
Mike
 
cLFlaVA and mike... don't forget to protect you CSS from older browsers with a comment... And Mike you wanted .25px yes?
Code:
<style type="text/css" media="print">
<!--
    body {
        margin-left: .25px;
        margin-right: .25px;
    }
-->
</style>
 
lol...

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
right margins of .25."
That's pixel's right??? ;p

I must not have been with it, his post was without units and then I saw the 25px and well...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top