8 replies [Last post]
Arterus
Arterus's picture
Offline
newbie
Last seen: 10 years 6 weeks ago
Timezone: GMT+1
Joined: 2012-10-04
Posts: 8
Points: 12

Hi again everyone,

I am sorry to come here with what appear to be wordpress questions, but I am trying to learn Wordpress and CSS together and am not really sure which one is giving me hassle in this respect.

I am on my second project now (my 5th or 6th if you include all the dummy projects I played with until getting a bit more serious) So I feel that I know how to do this already as I have implemented this process for each of them.

I have made a child theme, I have then made my own CSS files in the child themes folders (called the same as the original themes CSS) I have imported the original themes CSS files with @import ("path"), and yet no matter how much I change MY CSS files nothing changes on the site. It's like the original CSS ALWAYS has precedence over mine! Sad

I have checked very carefully the links, and the names etc. I am SURE that it 'should' work, yet the original CSS seems to take over!

The site isn't live I'm afraid I develop them locally, but I would appreciate any help you may be able to give.

Thanks for your help in advance.

Art.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 20 hours 24 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

Hi Arterus, I don't know much

Hi Arterus,
I don't know much about sub themes in wordpress.
It could be two things, the order of the stylesheets or specificity, maybe this will help understand specificity: http://specificity.keegan.st/

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 48 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

There probably is

There probably is insufficient detail to say exactly what the issue is.

In a child theme you have to have a file named same as parent 'style.css' in fact in any theme child or otherwise, it's less a file for adding styles as a file that the WP loader reads to understand what themes are available to the appearance dashboard page for activation.

It's odd that WP still follows this approach of @import of parent styles in it's examples and that style.css has any styles in at all; most themes avoid this and enqueue styles and scripts from the themes functions.php file, still this @import is a working principle and you should not be having trouble adding styles into your stylesheet after the import and having those rulesets applied so this may be as Tony points to a specificity issue in your rulesets are trying to overrule existing styles and failing as originals have more weight to them.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Arterus
Arterus's picture
Offline
newbie
Last seen: 10 years 6 weeks ago
Timezone: GMT+1
Joined: 2012-10-04
Posts: 8
Points: 12

Thank you both, I will have

Thank you both, I will have to get my CSS book out again to try and understand Specificity.

I appreciate your link Tony, but that generator meant absolutely nothing to me as a beginner, it looked as complicated as a Japanese brain surgery manual. I didn't have a clue what it was, what it did, or how to use it lol.. (like I say, I am just starting out Sad )

I will read up on Specificity and will post my progress. I have written to the maker of the theme, although I'm afraid he isn't english speaking and communication of what my actual problem is, is proving tricky.

But as I say, I will post my progress and let you know step by step how I fix this, as it may well help someone else one day.

Regards,

Art.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 20 hours 24 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

Hi Arterus, Yep it's not an

Hi Arterus,
Yep it's not an easy topic to get your head around.
I will try and explain it a little.
There are different types of selectors, green in the image below.

These different selectors have different weights or level of importance based on how specific they are.
Id's have to be unique on the page, so they are very specific. Classes can be reused so they are less specific.

If you look again at the link http://specificity.keegan.st/ you will see a button to the left "Sort by Specificity". If the selectors are complex it can help you see which are more specific.

Arterus
Arterus's picture
Offline
newbie
Last seen: 10 years 6 weeks ago
Timezone: GMT+1
Joined: 2012-10-04
Posts: 8
Points: 12

Thanks again Tony, I have

Thanks again Tony, I have been away and looked at the topic of Specificity and am proud to say that I now 'understand it' but of course getting to grips with it properly is going to take time.

The good news is I have managed to solve my problem!

by simply using !important I was able to change the specificity of the appropriate attributes and get my work done. I now appreciate 'why' a theme must be child theme compatible (as the one i'm using isn't - from the author himself)

Learning every day,

Thanks so much, The help I receive here is invaluable.

Art.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 48 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

!important is something I

!important is something I rant about in the WP/BP community daily it must not be used and is being used so much because plugin and theme authors over specify their rules then others go and add !important to try and override then someone else tries to style and is forced to use it, or someone thinks it's clever to use because then their style won't get ovverwritten unintentionally by another plugin stylesheet, it's all a viscous circle and indicative of the level of bad coding in the WP community born from a lack of experience.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Arterus
Arterus's picture
Offline
newbie
Last seen: 10 years 6 weeks ago
Timezone: GMT+1
Joined: 2012-10-04
Posts: 8
Points: 12

Hi Tony thanks for the heads

Hi Hugo, thanks for the heads up. Sorry I havn't been around to reply sooner too, as I again feel that this community is actually willing to help! Especially its moderators, and that speaks volumes!

As a beginner coder, I am struggling to decipher many things in the WP world. I said to my wife the other day that I felt the theme I was using was badly written, and this simply confirms it. Not only is it poorly written the code they write is all on one line, no indentation at all. My first job is to go through it and structure it visually before I can even attempt to pull it apart.

With all this in mind, I wonder what I can do myself to NOT release bad code? Obviously my knowledge is very minimal at the moment, although I grow in confidence every day with both PHP and CSS, but I am aware how bad programming can affect the end user, and as such want to steer clear of that as best I can.

Any Tips?

Thanks as always,

Art.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 48 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

All on a single line is

All on a single line is actually for a reason it's known as 'minifying' and is a means of shrinking the file size, it ought to be compiled though and the original format available really otherwise it's impossible for other devs to deal with but then WP allows for multiple styles sheets so one could/should add further styles through other sheets or child theme.

The only tip is experience I'm afraid and reading tech forums daily for snippets of advise, writing good code is not easily reduced to a few bullet points sadly.

Good formatting is half the battle though and although I don't hold with WP necessarily when it tries to lay down the law it does provide guidance and WP expected best practises for CSS /PHP formatting that they expect to be followed so check the codex.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me