0

I regularly work on a site where the style sheets require a full build and deploy to update, which is a big hassle and not worth it to update something basic like link styles.

I have a way I can apply my own styles through a CMS to avoid the full build and deploy, but I have to override with !important if the style is already defined in one of those sheets, or by using more specific selectors.

I don't believe there are negative consequences to using !important, though I know it is not a best practice because it can be tricky to maintain. But here is an example I'm not sure about. Let's say I have this bit of HTML:

            <p class="snaps">
                This is a bit of text followed <a class="snaps-link">by a link</a>
            </p>

and in one style sheet we have:

            .snaps {text-align: center; font-weight: bold;}

and in another style sheet the a element is defined like this:

            a { outline: none; color: #6D6E71; text-decoration: none;}

and I want to write a style like this, in the CMS (either through an external or internal style sheet):

            p.snaps a.snaps-link{color: orange; text-decoration: underline; font-weight: normal;}

Is there a problem with doing this? I am the only one at my company who knows anything about coding, so I don't have anyone to bounce ideas off of. And so I come to you...interested to hear what anyone thinks.

Another issue I run into is that I am frequently asked to remove elements. Often times the easiest way to do it is to use display: none and hide them. I think that can have SEO penalties if I am hiding text, but are there other consequences I'm not aware of?

Thank you.

surfbird0713
  • 1,209
  • 2
  • 23
  • 45

1 Answers1

0

There's nothing wrong with this CSS:

p.snaps a.snaps-link{color: orange; text-decoration: underline; font-weight: normal;}

What you're using there is called a combinator, and it's completely legit. Read more about combinators here.

Your method of display: none; is a fine solution. There shouldn't be any consequences to doing that that would effect you in any big negative way. If you can inject JavaScript through the CMS, you could use it to remove the element entirely.

Community
  • 1
  • 1
jamesplease
  • 12,547
  • 6
  • 47
  • 73
  • Thank you! This information is really helpful to me, I didn't realize I could use JavaScript to remove the elements. Learning on the job :) – surfbird0713 Dec 21 '12 at 16:39