Support » Everything else WordPress » Which is better, functions.php or style.css

  • Resolved another-webmaster


    Is it better (faster/more stable) to use a CSS code or function for following?
    To create two columns I have a function as following (just part of full code shown here):
    (left column)
    $content = '<div style="width: 45%; margin-right: 5%; float: left; text-align: justify; ">' . $content . '</div>';
    (right column)
    $content = '<div style="width: 45%; float: left; text-align: justify;">' . $content . '</div><div style="clear: both;"></div>';
    Using it with a shortcode it works like a charm but it is still a function.
    I could also use CSS code itself and create div+class in style.css (I only edit in html mode. I never use crappy visual editor).

    Does it matter which way I use or is it prefer to use the style.css above functions.php?
    Looking forward to answers, thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Kathryn


    Automattic Happiness Engineer

    I would add a class to your function and put the styles in your CSS as it’s always preferable to keep functionality and form separate.


    <div class="foo">
    .foo {
      width: 45%;
      margin-right: 5%;
      float: left;
      text-align: justify;

    You are so right with that, absolutely maam! but (sorry no offence) still it is as a function call.
    Maybe I didn’t explain what/how I meant the question above, sorry for that. To enlighten some by this sample;

    In a post/page we can do it 2 ways, the first way could be like this:
    (for left column):
    <div class="lcol"> the text here </div>
    (for right column):
    <div class="rcol"> the text here</div>
    And in style.css giving the correct codes for the classes, no shotcode is used this way.

    Second way can be done like this, clicking the created button (we did ourselfs, btn are lcol and rcol):
    [lcol]{txt here}[/lcol] and [rcol]{txt here}[/rcol]

    Using the shortcode methode is for our authors faster with same output results.

    But I actualy was/am curious if a plugin/function call needs more “load” from server than just the “regular” styling way by using “only” css code, as shown in the sample as above now.
    I ask that because our site (as it is now) has over 2/3k postings and I am a little afraid that plugins/function calls like these also will have a neg impact on server loads but maybe I am totally incorrect.

    Moderator Kathryn


    Automattic Happiness Engineer

    Ah – thanks for clarifying. Unfortunately I don’t know the answer to this one but hopefully someone else will chime in. I’ll see if some other folks might know.

    Putting it in your css reduces your server load because the browser will only load that css once (and keep it in cache).

    You can change your shortcode so that it outputs

    <div class="lcol"> the text here </div>

    instead of the inline styles.

    Thank you both for fast responding, will split up function and styling to where both belong 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Which is better, functions.php or style.css’ is closed to new replies.