Adding style attribute to <body> tag using CGI.pm

M

malatinszky

I am using the standard CGI module to output a HTML document. I would
like the <body> tag of the HTML doc to have a style attribute, like
this:

<body style="margin-left:5px;">

My thought was to writ

print $q->start_html(-style=>"margin-left:5px;");

but if I do that, what I get is

<link rel="stylesheet" type="text/css" href="margin-left:5px;" />

because -style is used as a shortcut to attach a style sheet.

How do I do this right?

Thanks,

Andras Malatinszky
 
T

TonyV

I am using the standard CGI module to output a HTML document. I would
like the <body> tag of the HTML doc to have a style attribute, like
this:

<body style="margin-left:5px;">

My thought was to writ

print $q->start_html(-style=>"margin-left:5px;");

but if I do that, what I get is

<link rel="stylesheet" type="text/css" href="margin-left:5px;" />

because -style is used as a shortcut to attach a style sheet.

How do I do this right?

Thanks,

Andras Malatinszky

Wow, I've never really thought about that before. I don't know what
the answer is, but here's a possible workaround:

print $q->start_html(-style=>{ -code=>"body: { margin-left:5px; }" });

This will attach a style to the body element in the page's header.
 
M

malatinszky

Wow, I've never really thought about that before. I don't know what
the answer is, but here's a possible workaround:

print $q->start_html(-style=>{ -code=>"body: { margin-left:5px; }" });

This will attach a style to the body element in the page's header.

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top