Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS best practice question

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #33761
    sdunham
    Member

    Still kind of new to web design, so sorry if this is stupid question…

    Assuming I’m working on a page in a CMS in which I only have control over the content of a given page (but can also use Javascript/jQuery), is it better practice to use inline CSS to style elements (there’s a lot of stuff to style), or to leave the markup clean and use a stylesheet by inserting a link tag into the page’s head with jQuery?

    I could also include a script tag outside of the head, but that would break validation (which I’d like to avoid).

    I’m assuming it’s best to use inline styling, but it’s so dang ugly… Any thoughts?

    Thanks!
    Scott

    #84363
    TheDoc
    Member

    Definitely still want to go with linking to a stylesheet.

    Prime scenario: what if those styles carry over to multiple pages?

    #84365
    OniLinkCR
    Member

    To extend what TheDoc said, it also makes your content load faster as you can cache, compress, and it’s just better to link it as opposed to use inline. Go with inline ONLY if you want to test something out quickly.

    #84376
    TheDoc
    Member

    “Go with inline ONLY if you want to test something out quickly.”

    And, really, that’s what Firebug or the Inspector tool is for!

    #84377

    My advice is easy to remember: Never use inline styles.

    #84379
    furrball1383
    Member

    I agree with everyone so far, always Always use style sheets!

    #84420
    sdunham
    Member

    Hmmm… I guess I was just assuming inline was better in this case since it didn’t rely on jQuery being loaded successfully, then a script being executed successfully before the styles are applied.

    Definitely happy that my assumption was incorrect, thanks everyone!

    #84428
    Johnnyb
    Member

    Which CMS are you using? Are you not able to add a conditional PHP statement in the header which loads the stylesheet only on that specific page? That way it takes reliance on JS out of the equation.

    #84435
    OniLinkCR
    Member

    Yah, if you are using WordPress do something like this



    load the style sheet via plain 'ol HTML



    #84446
    sdunham
    Member

    @Johnnyb and @OniLinkCR The CMS is BigTree by a company called FastSpot. If I had access to the PHP files, this is exactly what I’d do. Unfortunately I don’t have that level of access. Because of this, what I’m doing is already a hack of sorts. I guess I was just looking for the best way to implement that hack.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘CSS’ is closed to new topics and replies.