1

I am trying to customize some fonts in Google Apps Script, yet keep getting the same answer: Syntax error. (line 3, file "CSS"). This is my CSS.gs tab:

<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
var css={};
css.div = { fontFamily:"Courier New"};

Where have I gone wrong???

4
  • 1
    I don't think you can include HTML or CSS in a .gs file -- check developers.google.com/apps-script/guides/html/… Commented May 20, 2015 at 2:05
  • No, I can...Ive seen others with it Commented May 20, 2015 at 2:15
  • 1
    certainly not by putting an html tag inside javascript. must be in the html side Commented May 20, 2015 at 2:47
  • Can you show me how to do that? Google Developers has not been helpful for css. Commented May 20, 2015 at 12:36

1 Answer 1

1

Server-side Google Apps Script doesn't do anything directly to style HTML output on the client side.

Option 1: Include <style> tags in your HTML file (not in GS).

<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">

<style>
div { 
  fontFamily:"Courier New";
}
</style>

...

Option 2: Inline style, again in your HTML.

<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">

<div style='fontFamily:"Courier New";'>
...
</div>

Option 3: Use a separate HTML file for your css, which you import into your HTML. This is demonstrated in the Best Practices documentation, under Separate HTML, CSS, and JavaScript. Since the css isn't being linked as a stylesheet, but instead is imported HTML, you need to include the <style> tags.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.