Embedded Styles Not Working

This forum is for all Flare issues related to styles, stylesheets and XML.

Embedded Styles Not Working

Postby JPittmanOfLaMancha on Tue Jul 23, 2013 8:04 am

I have one page on which I wish to use a very specific style. Therefore, I see no need to create or modify an external stylesheet. However, when I try to embed any styles into this page, nothing happens.

Here is my code:

Code: Select all
    <head>
        <style type="text/css">
         body
         {
            font-size:40px;
            background-color:red;
         }
         .test
         {
            font-size: 20px;
            color: red;
            font-weight:bold;
         }
      </style>
    </head>
    <body>
        <h1>Videos: Demonstrations and Tutorials</h1>
        <div class="test">
         <p class="test">This is a test.</p>
      </div>
    </body>


And here is a screenshot of the results (or lack thereof):
SnagIt_7-23-2013_10.00.23.png


I'd appreciate any help figuring out why my embedded styles aren't being applied.
You do not have the required permissions to view the files attached to this post.
JPittmanOfLaMancha
Propeller Head
 
Posts: 10
Joined: Fri Jun 10, 2011 6:48 am

Re: Embedded Styles Not Working

Postby LTinker68 on Tue Jul 23, 2013 12:00 pm

When the output is built, the code in the masterpage is used for the head and body blocks and the content from within the body tags in the topic are inserted between the body tags in the masterpage to build a final, compiled topic page. So your in-page styles are being blown out at build time because that code isn't in the masterpage.

Your project already has an external stylesheet by default. You don't need to create a new one, so you can just add your styles to the topic stylesheet (Styles.css or Modern.css by default). However, since you're trying to modify the body tag definition, you'll need to go one step further. I don't think creating a body class and applying that body class in the topic will work because I think the body tag is replaced from the masterpage. So you have two options.

Option 1: Put all the content inside that topic into a div and apply a class that you've added to the topic stylesheet (e.g., div.specialBkg). Set the div class to have 0 margin and 0 padding so that it fills the body tag entirely, then add the style definitions to that div class that you would have applied to the body class (font size and background color).

Option 2: Create a second masterpage and add the style definitions to the head tag as you tried to do to the topic, or add the styles to the topic stylesheet and create a body class and apply that class to the body tag in the new masterpage. In the stylesheet, create an html class and point that class to the masterpage you just created. Then in the topic, apply that class to the html tag. When you build the output, that one topic will use the new masterpage and styles instead of the default masterpage.

Both options allow you to reuse this special look on other topics, so either will work. However, the first option creates an additional tag level, which may affect how some other styles appear in the page, depending on how you have the styles set up. I'd probably be more apt to go with Option 2 with a new body class in the stylesheet that's applied to the body tag of the new masterpage.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
LTinker68
Master Propellus Maximus
 
Posts: 7245
Joined: Thu Feb 16, 2006 9:38 pm

Re: Embedded Styles Not Working

Postby subquark on Tue Jul 02, 2019 11:52 am

Thank you Lisa! Six years later and this is still very good advice that works well.
User avatar
subquark
Propeller Head
 
Posts: 19
Joined: Mon Mar 18, 2013 1:11 pm
Location: Portsmouth, NH


Return to Styles, Stylesheets and XML

Who is online

Users browsing this forum: No registered users and 1 guest