Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

embedding inherited style inside body?

0 views
Skip to first unread message

Mike Jansen

unread,
Aug 10, 2006, 9:51:52 AM8/10/06
to
Is there a way to override inline within the <body> a style of an element
but not do it with a style attribute on the element?

Here's my delimma:

I'm generating HTML. I don't have access to the <head>. In the <head> is a
stylesheet that defines a style for <p>. I have HTML I am wrapping around
other generated HTML (that I don't have access to) that emits a <p> tag, and
its getting (obviously) the style from the stylesheet. So I'd like to be
able to override the style via some surrounding elements.

Example

<html>
<head><style type="text/css">p { bottom-margin: 20px; }</style></head>
<body>
<!-- POINT A: begin what i have control over -->
<div style="position:absolute; top:0px; right:0px;">
<!--begin more stuff i don't have control over -->
<p>TheOtherGeneratedStuff</p>
<!-- back to me again-->
</div>
...

So somewhere at POINT A, I'd like to insert something that affects the style
of the embedded <p> tag that I don't have control over. Could I just insert
some java script to save and restore the <p> style ? Other options?

Thanks,
Mike


Eric

unread,
Oct 27, 2006, 9:28:25 PM10/27/06
to
If I'm not mistaken, I'm pretty sure that the way CSS works, styles within
the HTML take precedence over external stylesheets... also, more specific
styles have precedence over less specific styles. You ought to be able to
insert your style within Point A, and restore the old style by ending the
div... unless there is something else that is prohibiting that?

If you know what the markup is and simply don't have access to change it, I
suppose you could look for some exact pattern and match it... for example,
if it's a <p> within a <table> within a <form>, you could insert "form table
p { ...your code here ... }". Would that work, perhaps?

I'm really new to CSS myself, just thought I'd take a crack at this.

-- Eric


"Mike Jansen" <mjanse...@mail.com> wrote in message
news:OdfSlQIv...@TK2MSFTNGP03.phx.gbl...

0 new messages