Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 10:20 PM
David Filmer
Guest
 
Posts: n/a
Default How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

Greetings. I want to localize a style definition to a portion of an
HTML document, but use an external stylesheet. It seems that I can
only do
<style><!-- @import url(styles/my_style.css);--></style>
and <link rel=stylesheet href=styles/my_style.css type=text/css>
in the header, which applies to the entire HTML document and is NOT
what I want to do.

This does not seem to work:
<span style = @import url('styles/my_style.css');>
... some ...
... HTML ...
</span>

Nor does this:
<span>
<!-- @import url('styles/my_style.css'); -->
... some ...
... HTML ...
</span>

How do I "import" an external stylesheet at the inline or block level?
Thx!
  #2  
Old July 20th, 2005, 10:20 PM
Darin McGrew
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

David Filmer <IneverReadAnythingSentToMe@hotmail.com> wrote:[color=blue]
> Greetings. I want to localize a style definition to a portion of an
> HTML document, but use an external stylesheet.[/color]

In your HTML, use a CLASS attribute to mark desired the portion of your
document, for example:

<div class="yaddayaddayadda">
...
</div>

In your CSS, use appropriate selectors to style the content within that
portion of your document, for example:

.yaddayaddayadda p { ... }
.yaddayaddayadda a:link { ... }
.yaddayaddayadda a:visited { ... }
--
Darin McGrew, mcgrew@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, darin@htmlhelp.com, http://www.HTMLHelp.com/

"Men build too many walls and not enough bridges." - Sir Isaac Newton
  #3  
Old July 20th, 2005, 10:20 PM
DB McGee
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

David Filmer wrote:[color=blue]
> Greetings. I want to localize a style definition to a portion of an
> HTML document, but use an external stylesheet. It seems that I can
> only do
> <style><!-- @import url(styles/my_style.css);--></style>
> and <link rel=stylesheet href=styles/my_style.css type=text/css>
> in the header, which applies to the entire HTML document and is NOT
> what I want to do.
>
> This does not seem to work:
> <span style = @import url('styles/my_style.css');>
> ... some ...
> ... HTML ...
> </span>
>
> Nor does this:
> <span>
> <!-- @import url('styles/my_style.css'); -->
> ... some ...
> ... HTML ...
> </span>
>
> How do I "import" an external stylesheet at the inline or block level?
> Thx![/color]

You can't. What you could try perhaps, is to assign an id to each span, then
use the id selector to select styles. For example,

<span id="level1">
<h1>This should be orange</h1>
<p>This should be blue</p>
</span>

<span id="level2">
<h1>This should be purple</h1>
<p>This should be red</p>
</span>


Then in your stylesheet:

/* Level 1 Styles */
span#level1 p { color: blue; }
span#level1 h1 { color: orange; }

/* Level 2 Styles */
span#level2 p { color: red; }
span#level2 h1 { color: purple; }


You could thus define a whole series of variations on your styles. Not sure at
all if this is what you are trying to do?


  #4  
Old July 20th, 2005, 10:20 PM
Harlan Messinger
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

"DB McGee" <noreply@noreply.com> wrote:
[color=blue]
>
>You can't. What you could try perhaps, is to assign an id to each span, then
>use the id selector to select styles. For example,
>
><span id="level1">
> <h1>This should be orange</h1>
> <p>This should be blue</p>
></span>[/color]

Not <span>, <div>. You can't put block elements (like H1 and P) inside
a span.


--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.
  #5  
Old July 20th, 2005, 10:20 PM
DB McGee
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

Harlan Messinger wrote:[color=blue]
> "DB McGee" <noreply@noreply.com> wrote:
>[color=green]
>>
>> You can't. What you could try perhaps, is to assign an id to each
>> span, then use the id selector to select styles. For example,
>>
>> <span id="level1">
>> <h1>This should be orange</h1>
>> <p>This should be blue</p>
>> </span>[/color]
>
> Not <span>, <div>. You can't put block elements (like H1 and P) inside
> a span.[/color]

You're absolutely correct - I missed that :)


  #6  
Old July 20th, 2005, 10:21 PM
David Filmer
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

> You could thus define a whole series of variations on your styles. Not sure[color=blue]
> at all if this is what you are trying to do?[/color]

Hi, thanks for the feedback. I do think that prehaps I should clarify
my intent a bit.

I'm working on a Boy Scout website. If you have a look at
http://troop606.com you will see that the mainpage includes a snippet
of the Troop calendar. The current calendar does not employ
stylesheets.

I'm working on a new version of the site that uses the open-source
"Plans" calendar (http://planscalendar.com/demo) which is rather
highly styled (http://planscalendar.com/demo/theme/plans.css). I want
to also include a snippet of this calendar on my site's mainpage (same
as I do with http://troop606.com). I don't want my snippet to be
dependent on changes that I make to the Plans .css file (which may not
be compatible with (or may be overwritten by) future versions of
Plans). I don't know how to apply the stylesheet to ONLY the calendar
snippet (and not the rest of the mainpage).

The calendar snippet HTML and the .css are from Plans. All I'm trying
to do is extract a portion of that HTML (which I know how to do) and
display it on my mainpage, with the .css applied (which I don't know
how to do).

I would very much appreciate any assistance.
  #7  
Old July 20th, 2005, 10:21 PM
Eric Bohlman
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

IneverReadAnythingSentToMe@hotmail.com (David Filmer) wrote in
news:e4c916dd.0401161142.6cc65c45@posting.google.c om:
[color=blue]
> I'm working on a new version of the site that uses the open-source
> "Plans" calendar (http://planscalendar.com/demo) which is rather
> highly styled (http://planscalendar.com/demo/theme/plans.css). I want
> to also include a snippet of this calendar on my site's mainpage (same
> as I do with http://troop606.com). I don't want my snippet to be
> dependent on changes that I make to the Plans .css file (which may not
> be compatible with (or may be overwritten by) future versions of
> Plans). I don't know how to apply the stylesheet to ONLY the calendar
> snippet (and not the rest of the mainpage).
>
> The calendar snippet HTML and the .css are from Plans. All I'm trying
> to do is extract a portion of that HTML (which I know how to do) and
> display it on my mainpage, with the .css applied (which I don't know
> how to do).[/color]

In the HTML, wrap the section you want to style in a <div> element with its
class attribute set to some name of your choosing, e.g.
<div class="styled">A bunch of stuff</div>. Then make a copy of the css
file for plans and prefix each selector with ".styled " (or whatever class
name you chose); don't leave out the trailing space. That will make all
the rules apply only to the contents of the <div> you added to the HTML.
  #8  
Old July 20th, 2005, 10:22 PM
Michael Rozdoba
Guest
 
Posts: n/a
Default Re: How to use EXTERNAL stylesheets for INLINE or BLOCK-LEVEL HTML?

Eric Bohlman wrote:
[color=blue]
> In the HTML, wrap the section you want to style in a <div> element with its
> class attribute set to some name of your choosing, e.g.
> <div class="styled">A bunch of stuff</div>. Then make a copy of the css
> file for plans and prefix each selector with ".styled " (or whatever class
> name you chose); don't leave out the trailing space. That will make all
> the rules apply only to the contents of the <div> you added to the HTML.[/color]

I was about to say something similar, but with the probably obvious
caveat that if the snipped section of html relies on styles applied to
any parent elements (say the body background colour), you'd have to do a
bit of tweaking, probably applying those styles, or a variant, to the
div you're enclosing the snippet in.

--
Michael
m r o z a t u k g a t e w a y d o t n e t
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles