ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

css as snippet

January 26, 2011 5:34am

Subscribe [5]
  • #1 / Jan 26, 2011 5:34am

    welshartnow

    81 posts

    I’m finding it convenient to include css blocks as snippets.  Are there any issues around this?

    [Mod Edit: Moved to the EE 2 Technical Support forum]

  • #2 / Jan 26, 2011 4:12pm

    Ingmar

    29245 posts

    I’m not sure I fully understand what that means. Can you show us a little more code, perhaps give an example?

  • #3 / Jan 27, 2011 4:28am

    welshartnow

    81 posts

    I’m entering the block of code shown below as a snippet(design>templates>snippets)as opposed to containing it within an external stylesheet is this ok, are there any issues arround it?

    <style type="text/css">
            /* style use for example */
            body {
                background-color:#EEE;
                height:100%;
          
            }
            .p-title {
                font-size:115%;
                color:#A80733;
                            font-weight:bold;
                            
            }
            .cap-title{
                font-size:115%;
                color:#A80733;
    
    font-weight:bold;
    
                
                
            }
        </style>
  • #4 / Jan 27, 2011 4:22pm

    Ingmar

    29245 posts

    No immediate issues that I can think of. Does it work as expected?

  • #5 / Jan 31, 2011 10:39pm

    erier

    55 posts

    Not that this will not work, but I would advise against inline CSS snippets. They will simply not validate through W3C standards.

    No reason not to include it in your external CSS!

  • #6 / Feb 01, 2011 2:33am

    Greg Aker

    6022 posts

    Sorry, Fat Free Interactive, but there is nothing wrong with inline css and valid html/xhtml.  View the source at google.com, yahoo.com, etc.  They aren’t failing validation with inline CSS.  😉

  • #7 / Feb 01, 2011 9:48am

    erier

    55 posts

    Greg, perhaps I should have been more specific :

    With modern HTML5 markup, this will not validate:

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <title></title>
        </head>
        <body>
        
        <div id="wrapper">    
            <style type="text/css">
                #style-a {display: block;}
            </style>
        </div>
    
        </body>
    </html>

    Please notice I specified W3C standards as well ...

    ... will simply not validate through W3C standards ...

    . Not google, yahoo, etc ...

    If you place the snippet in the head of the document, it will validate, however.

    Bottom line, put your CSS in an external style sheet. If you, for some reason, cannot - make sure to place it within the head of your document.

    Thanks.

  • #8 / Feb 01, 2011 6:46pm

    Lisa Wess

    20502 posts

    Since this isn’t an EE specific issue, I’ve moved it down to general for input from our wonderful community of designers.

    Thanks!

  • #9 / Feb 01, 2011 7:16pm

    mhughes73

    60 posts

    Agreed Fat Free Interactive. It’s generally best practice to not use inline styles.

  • #10 / Feb 03, 2011 8:08pm

    greggypetty

    2 posts

    I’ve got to agree with Fat Free Interactive too.  CSS can be tough stuff.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases