SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Inline css?

  1. #1
    SitePoint Zealot bemmott's Avatar
    Join Date
    Mar 2007
    Location
    NY, USA
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Inline css?

    Howdy all,
    I am doing a special page on my website (CSS validated) for access by a selected few. I am using my regular stylesheet for the page layout, but for this page only I want to have a different style for my links.

    Here is an example of the text and link:
    <h2>Audacity</h2>
    <p>Audacity is a free, easy-to-use audio editor and recorder for Windows, Mac OS X, GNU/Linux, and other operating systems. You can use Audacity tobr>

    * Record live audio.<br>
    * Convert tapes and records into digital recordings or CDs.<br>
    * Edit Ogg Vorbis, MP3, and WAV sound files.<br>
    * Cut, copy, splice, and mix sounds together.<br>
    * Change the speed or pitch of a recording.<br>
    * And more! </p>
    <a href="http://sunrisersalumni.org/files/audacity1.2.exe">Download</a>

    I don't need a style for hover, but want to make the word "download" colored white. Followed link is not important, either. So I assume that it - while not best form - would suffice to use inline styles for this thing? I don't want to add to my stylesheet and have any effect on the rest of the sites page links.

    Thanks for any guidance.
    Bruce ...

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,157
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    style a link

    I would give the link an id and style it "in the head" using a style tag after all of the "site-wide" CSS.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mittineague's solution will work, but because you mention "links" (plural), you would need to assign the links a class and then style the class in the head.

    But, if all of the links on this page will have the same style, I would give the <body> tag an ID, then style the child anchors:

    body#unique_id a {myStyle:myValue;}

    And, I would add this to the global style sheet rather than embedding it in the head. Chances are that you'll end up wanting to use the same style elsewhere in the site sometime.

    John

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Or create a second css file and add that in the head AFTER the first stylesheet, to redefine and apply the new styles you wish, and only place it in the head of the appropriate page(s). The second files only contains the new styles and nothing else.

    This way you could also alter any other styles as well in the second css file.

  5. #5
    SitePoint Zealot bemmott's Avatar
    Join Date
    Mar 2007
    Location
    NY, USA
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, guys. I think I will do some reading on Dr.Johns idea - that sounds like something I'd be capable of doing. I'm far from an expert with CSS, but I'm learning as I go.

    Appreciate it
    Bruce ...

  6. #6
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No reading required - with two stylesheets in the head, all the rules of the first one are applied. then all the rules of the second one are applied, which includes over-writing any selectors etc from the first one.

    Eg from first css file body {background-color: red; }
    then from second one body {background-color:blue; }
    The last rule is the one applied.
    so no need to alter the one that currently works by adding bits and then getting confused. just add the changes to the second file.

  7. #7
    SitePoint Zealot bemmott's Avatar
    Join Date
    Mar 2007
    Location
    NY, USA
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr John View Post
    No reading required - with two stylesheets in the head, all the rules of the first one are applied. then all the rules of the second one are applied, which includes over-writing any selectors etc from the first one.

    Eg from first css file body {background-color: red; }
    then from second one body {background-color:blue; }
    The last rule is the one applied.
    so no need to alter the one that currently works by adding bits and then getting confused. just add the changes to the second file.
    That's all I have to do? I can handle that. Thanks!
    Bruce ...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •