Embedding CSS in HTML Files

This forum is for all Flare issues not related to any of the other categories.
Post Reply
Ken S
Propeller Head
Posts: 26
Joined: Fri Aug 14, 2009 2:15 pm

Embedding CSS in HTML Files

Post by Ken S »

Is there a way in Flare to "embed" the CSS code in an HTML file rather than referring to it in a separate file? By "embed", I mean something like this:

Code: Select all

<head>
     ...
     <style>
      body
      {
	font-family: Arial;
      }
      h1
      {
	font-weight: bold;
	font-size: 24.0pt;
      }
     ...   
     </style>
     ...
</head>
Rather than this:

Code: Select all

<head>
        ....
        <link href="Resources/Stylesheets/Styles.css" rel="stylesheet" type="text/css" />
        ...
</head>
carolynmwallace
Sr. Propeller Head
Posts: 168
Joined: Thu Jan 31, 2008 12:21 pm
Location: Durham, NC

Re: Embedding CSS in HTML Files

Post by carolynmwallace »

Are you talking about for one HTML file or for all of them?

If it's just one file, you could do it with the Text Editor. I don't know a method that would let you do it for all HTML files.

Is there a particular reason you need to do this? It's ordinarily discouraged because it makes it more difficult to change styles down the road since, instead of making one change to the master style sheet, you have to update every HTML file that has embedded styles.
Ken S
Propeller Head
Posts: 26
Joined: Fri Aug 14, 2009 2:15 pm

Re: Embedding CSS in HTML Files

Post by Ken S »

Thanks Carolyn.

The reason I asked about this is that I'm working on a project that includes, among other items, an e-mail newsletter. One of the requirements for the e-mail newsletter is embedded CSS. I'm thinking of using Flare for this project and wanted to verify that it can support this.
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Embedding CSS in HTML Files

Post by wclass »

I have done it in one file using a text editor - I put it into a html page that I wanted to reuse outside Flare. You could probably put it into a template but I haven't tried that.

The code was inserted into the head and looked like ...

Code: Select all

    <head>
        <style type="text/css">
		body {
			font-family: Verdana, sans-serif;
			font-size: 8pt;
		}    	
		p {
			font-family: Verdana, sans-serif;
			font-size: 8pt;
			margin-top: 2pt;
			margin-bottom: 2pt;
		}
		ul {
			font-size: 8pt;
			margin-top: 2pt;
			list-style-type: square;
		}
		
		li {
			font-size: 8pt;		
			margin-bottom: 2pt;
			margin-top: 2pt;
			padding-left: 6pt;
		}
		    	
    	</style>
    </head>
Margaret Hassall - Melbourne
GregStenhouse
Sr. Propeller Head
Posts: 330
Joined: Tue May 13, 2008 3:27 pm
Location: Christchurch, New Zealand

Re: Embedding CSS in HTML Files

Post by GregStenhouse »

I think any code you place in the head of a topic (after opening in the text editor) is wiped after you build, and replaced with code from the masterpage. So I think you'd need to create a special master page and apply that to your topic.
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Embedding CSS in HTML Files

Post by RamonS »

How many styles are that? I'd put them into the main CSS and name them differently or craft a second CSS and reference that for the topic.
KevinDAmery
Propellus Maximus
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Embedding CSS in HTML Files

Post by KevinDAmery »

RamonS wrote:How many styles are that? I'd put them into the main CSS and name them differently or craft a second CSS and reference that for the topic.
Wouldn't work for an email unless you could host the css somewhere.

To answer the OP's question, you might be able to embed the style info in the master page (I haven't confirmed that that doesn't get stripped out, but in theory it should work...); failing that, you could generate the HTML output, then manually add the style info to the head prior to putting the HTML into the email. Presumably you have to copy the HTML into an email client anyway for sending since Flare doesn't output directly to email formats, so adding the style info as part of that process shouldn't be too onerous.
Until next time....
Image
Kevin Amery
Certified MAD for Flare
carolynmwallace
Sr. Propeller Head
Posts: 168
Joined: Thu Jan 31, 2008 12:21 pm
Location: Durham, NC

Re: Embedding CSS in HTML Files

Post by carolynmwallace »

Ken S wrote:The reason I asked about this is that I'm working on a project that includes, among other items, an e-mail newsletter. One of the requirements for the e-mail newsletter is embedded CSS. I'm thinking of using Flare for this project and wanted to verify that it can support this.
Will styles in the HEAD section work for email newsletters? I produce an email newsletter for my company, and the only way I can get embedded CSS to work is if I use inline styles. Anything CSS I put in the HEAD section is ignored. :( (I'm using a regular HTML page and Outlook.)
KevinDAmery
Propellus Maximus
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Embedding CSS in HTML Files

Post by KevinDAmery »

carolynmwallace wrote:
Ken S wrote:The reason I asked about this is that I'm working on a project that includes, among other items, an e-mail newsletter. One of the requirements for the e-mail newsletter is embedded CSS. I'm thinking of using Flare for this project and wanted to verify that it can support this.
Will styles in the HEAD section work for email newsletters? I produce an email newsletter for my company, and the only way I can get embedded CSS to work is if I use inline styles. Anything CSS I put in the HEAD section is ignored. :( (I'm using a regular HTML page and Outlook.)
It should in theory, but of course the difference between theory and practice is that in theory there's no difference.
Until next time....
Image
Kevin Amery
Certified MAD for Flare
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: Embedding CSS in HTML Files

Post by RamonS »

KevinDAmery wrote:
RamonS wrote:How many styles are that? I'd put them into the main CSS and name them differently or craft a second CSS and reference that for the topic.
Wouldn't work for an email unless you could host the css somewhere.
Then I misunderstood. So the email message itself is supposed to get styling via CSS?? I guess I exclude myself from this discussion then, because I am a strong believer that HTML and CSS are meant for web pages, not emails.
carolynmwallace
Sr. Propeller Head
Posts: 168
Joined: Thu Jan 31, 2008 12:21 pm
Location: Durham, NC

Re: Embedding CSS in HTML Files

Post by carolynmwallace »

RamonS wrote:Then I misunderstood. So the email message itself is supposed to get styling via CSS?? I guess I exclude myself from this discussion then, because I am a strong believer that HTML and CSS are meant for web pages, not emails.
But in this case, the web page IS the email. Bwah-ha-ha-ha! :twisted:
KevinDAmery
Propellus Maximus
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Embedding CSS in HTML Files

Post by KevinDAmery »

RamonS wrote:
KevinDAmery wrote:
RamonS wrote:How many styles are that? I'd put them into the main CSS and name them differently or craft a second CSS and reference that for the topic.
Wouldn't work for an email unless you could host the css somewhere.
Then I misunderstood. So the email message itself is supposed to get styling via CSS?? I guess I exclude myself from this discussion then, because I am a strong believer that HTML and CSS are meant for web pages, not emails.
It is supported by the email spec and by some email clients, so it's not an invalid idea. Sure, someone could inject some malicious code into the email HTML, but they could do the same with a website, too.
Until next time....
Image
Kevin Amery
Certified MAD for Flare
Post Reply