WordPress.org

Ready to get started?Download WordPress

Forums

CSS style selectors (5 posts)

  1. mx760
    Member
    Posted 2 years ago #

    Hi, for my main body, I have defined a class:heading,subheading,paragraphs for styling the heading, subheading, paragraph respectively in style.css, but my problem is how do I indicate to wordpress when I want to use a certain style for the text?

    I tried in the WP admin HTML Editor by adding:

    <div class="heading">
    I AM A HEADING</div>

    <div class="subheading">
    I AM SUBHEADING
    </div>

    <div class="paragraph">
    the quick brown fox jumps over the lazy dog.
    the quick brown fox jumps over the lazy dog.
    the quick brown fox jumps over the lazy dog.
    </div>

    BUT that didn't work and only displayed the text (without style) if I remove the class selectors.

  2. Patrick Nommensen
    Member
    Posted 2 years ago #

    Please use the code feature in the future.

    <div class="heading">
    I AM A HEADING</div>
    
    <div class="subheading">
    I AM SUBHEADING
    </div>
    
    <div class="paragraph">
    the quick brown fox jumps over the lazy dog.
    the quick brown fox jumps over the lazy dog.
    the quick brown fox jumps over the lazy dog.
    </div>
  3. bcwp
    Member
    Posted 2 years ago #

    I recommend you use the standard HTML tags for this task, unless you have a really good reason to do differently. So, your main heading would be an H1 tag, and your subheadings could be anything from H2 to H6 tags. Paragraphs should use P tags. You can then style them in your CSS file like so:

    h1 { color: red; }
    h2 { color: blue; }
    p { color: green; }

    or, if you want to only style a specific class of these, you could do something like:

    h1.heading { color: red; }
    h2.subheading { color: blue; }
    p.paragraph { color: green; }

    To assign the classes to your content, you may have to edit your PHP files in a text editor or use the HTML editing tab in the WordPress content editor... depending on your situation.

  4. katmac_aus
    Member
    Posted 2 years ago #

    What theme are you using? If you theme has an editor-styles.css stylesheet included you can updated this with your custom styles and that way you will be able to see them take effect in the editor, not just when you view the published version.

  5. mx760
    Member
    Posted 2 years ago #

    Since I'm using my own custom theme, I just have style.css. So I should just edit in WordPress Admin HTML editor for a certain page to have that class selectors, BUT when I tried with putting this:

    <div class="heading">I am a heading</div>

    it's not being displayed where I want it, you see, I have a mainContent div that holds mainContentItem divs and these textual styles (.heading, .subheading, .paragraph) are to reside inside the mainContentItem div, but by using WP admin HTML editor, it's not placed there AND another problem is since index.php has the Loop, ALL my pages show the out-of-placed styled text, BUT I only want it to show on ONE of my pages...

    Man, I hope someone can help me out, thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags