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

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

am 06.12.2007 20:10:24 von malatinszky

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



My thought was to writ

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

but if I do that, what I get is



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

How do I do this right?

Thanks,

Andras Malatinszky

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

am 06.12.2007 21:01:21 von kingskippus

On Dec 6, 2:10 pm, malatins...@gmail.com wrote:
> I am using the standard CGI module to output a HTML document. I would
> like the tag of the HTML doc to have a style attribute, like
> this:
>
>
>
> My thought was to writ
>
> print $q->start_html(-style=>"margin-left:5px;");
>
> but if I do that, what I get is
>
>
>
> 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.

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

am 06.12.2007 21:18:45 von malatinszky

On Dec 6, 3:01 pm, TonyV wrote:
> On Dec 6, 2:10 pm, malatins...@gmail.com wrote:
>
>
>
> > I am using the standard CGI module to output a HTML document. I would
> > like the tag of the HTML doc to have a style attribute, like
> > this:
>
> >
>
> > My thought was to writ
>
> > print $q->start_html(-style=>"margin-left:5px;");
>
> > but if I do that, what I get is
>
> >
>
> > 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.

Thank you.