Forums

[resolved] How to use an external CSS file with my posts (7 posts)

  1. papa4174
    Member
    Posted 3 years ago #

    I put a css file here:
    /public_html/wp-content/themes/mytheme/test.css

    How can I edit this code to make it point to this external css file?

    Thanks!

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="/test.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <p><span class="offerlink">Click Me</span></p>
    </body>
    </html>

  2. stvwlf
    Member
    Posted 3 years ago #

    <title>Untitled Document</title>
    <link href="<?php bloginfo('template_directory'); ?>/test.css" rel="stylesheet" type="text/css" />
    </head>
  3. papa4174
    Member
    Posted 3 years ago #

    stvwolf mind helping edit this code.

    I put my css file in:
    /public_html/wp-content/themes/mytheme/test.css

    here is the html code I put in a new post:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="<?php bloginfo('template_directory'); ?>/test.css" rel="stylesheet" type="text/css" />
    </link></head>
    <body>
    <p><span class="cssname">Click Me</span></p>
    </body>

    Here is the code in my css:
    @charset "utf-8";
    .cssname {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #FF6699;
    text-decoration: underline;

    Not sure what I'm doing wrong

  4. stvwlf
    Member
    Posted 3 years ago #

    You didn't explain what the problem is.

    For one thing you are missing a closing } on .cssname

    however I don't know what .cssname relates to or what you are asking for.

  5. papa4174
    Member
    Posted 3 years ago #

    oops I did forget the }

    inside of my external file, .cssname is the style name

    so I want the the text "Click Me" to be styled by the css file.

    but right now my text Click Me in my latest post on my blog is still black. If it were styled by the external css file it should be pink.

  6. buddha trance
    Member
    Posted 3 years ago #

    Using <head> tags and such in the post won't work. That is already called by header.php.

    Simply add the css to the theme main style.css
    Or if it is a one time thing, do <span style="your css here;">

    Is there a specific reason why you need an external test.css? If so, add the call from header.php of your theme.

  7. papa4174
    Member
    Posted 3 years ago #

    thanks buddha! worked like a charm!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.