- This topic is empty.
-
AuthorPosts
-
August 2, 2011 at 7:37 pm #33761
sdunham
MemberStill 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!
ScottAugust 2, 2011 at 8:05 pm #84363TheDoc
MemberDefinitely still want to go with linking to a stylesheet.
Prime scenario: what if those styles carry over to multiple pages?
August 2, 2011 at 8:32 pm #84365OniLinkCR
MemberTo 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.
August 3, 2011 at 12:28 am #84376TheDoc
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!
August 3, 2011 at 12:38 am #84377joshuanhibbert
MemberMy advice is easy to remember: Never use inline styles.
August 3, 2011 at 12:55 am #84379furrball1383
MemberI agree with everyone so far, always Always use style sheets!
August 3, 2011 at 2:37 pm #84420sdunham
MemberHmmm… 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!
August 3, 2011 at 3:33 pm #84428Johnnyb
MemberWhich 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.
August 3, 2011 at 5:39 pm #84435OniLinkCR
MemberYah, if you are using WordPress do something like this
load the style sheet via plain 'ol HTML
August 3, 2011 at 8:43 pm #84446sdunham
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.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.