WordPress.org

Forums

External CSS style for images in posts (4 posts)

  1. 248
    Member
    Posted 5 years ago #

    Hi,

    I would like to ask someone, if is possible to connect images in posts or pages with some external CSS to format them.

    I know, that is possible co write CSS into the field under Advanced img properties. It works, but in case, when I want to change image styles of all my imgs, I just feel the need to have one simple external CSS, which is connected to all my posted images.

    Is there any chance to have just a tiny CSS file for formating images inserted in posts and pages?

    Thx!

  2. stvwlf
    Member
    Posted 5 years ago #

    yes, external will work fine. It doesn't even need to be a separate file. You can add the CSS to the bottom of your theme's style.css stylesheet if that is convenient.

    to add a separate sheet, add this line below the line in header.php that defines your theme's style.css
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/my_stylesheet.css" type="text/css" media="screen" />
    Sub the name of your sheet for "my_stylesheet".

    One thing to keep in mind - CSS has rules for application of styling. Styling applied directly to a tag using style="" will override styling in a stylesheet. Also, general styling like img { border: 1px solid #fff } is overriden by more specific styling like #content .post img { border: 1px solid #fff }

    What that means is, if you don't see the styling you add to the stylesheet being applied, it doesn't mean you necessarily did it incorrectly. It could be that it is getting overriden and you need to make your stylesheet styling more specific.

    I find the best way to test and debug styling issues is with Forefox's Firebug extension - it shows you exactly how styling rules are being applied and overriden.

  3. s_ha_dum
    Member
    Posted 5 years ago #

    There are some classes assigned to the images that you could use. You could also do something like .entry * img {...}. But those are just examples. There are numerous ways to target those images, depending upon the scope you want.

  4. 248
    Member
    Posted 5 years ago #

    Thanks guys!

    Great! Thanks a lot... :-}

Topic Closed

This topic has been closed to new replies.

About this Topic