Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Best way to specify text colour?

Options
  • 15-01-2013 6:41pm
    #1
    Registered Users Posts: 1,977 ✭✭✭


    Hi,
    I have a bit of html code with text in it and I want to specify a colour to some words. Can anybody tell me the best way to do this?

    Thanks.


Comments

  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 2,588 Mod ✭✭✭✭KonFusion


    There's a few ways. Some more semantically correct than others.

    How many different colors?

    Any chance you could post a snippet of the code?


  • Registered Users Posts: 1,977 ✭✭✭euser1984


    KonFusion wrote: »
    There's a few ways. Some more semantically correct than others.

    How many different colors?

    Any chance you could post a snippet of the code?

    Just one colour. I want the Peter and test to be #FACC2E

    <p>
    </br>
    test test test,</br>
    <i>Peter & test.</i>
    </p>


  • Registered Users Posts: 1,082 ✭✭✭Feathers


    euser1984 wrote: »
    Just one colour. I want the Peter and test to be #FACC2E
    <p>
    </br>
    test test test,</br>
    <i>Peter & test.</i>
    </p>
    

    The 'correct way' to do this (i.e. seen as best practice in industry & more powerful) is to you stylesheets. If you want to add the blue colour to all <i> tags within all <p> tags, the stylesheet would look like this:
    <style>
      p  i  {
          color: #FACC2E;
      }
    </style>
    

    The language in the style tag above is called CSS (which stands for cascading style-sheets). You can read more about it here.

    Just shout if you've any questions on it. Though as a tip, people will be much more responsive if you give details & post an example of what you've already tried to solve the problem yourself — I'm want to do X, I've already tried doing Y which didn't seem to work; it did Z, which I wasn't expected. Good luck! :)


  • Registered Users Posts: 1,977 ✭✭✭euser1984


    Feathers wrote: »
    The 'correct way' to do this (i.e. seen as best practice in industry & more powerful) is to you stylesheets. If you want to add the blue colour to all <i> tags within all <p> tags, the stylesheet would look like this:
    <style>
      p  i  {
          color: #FACC2E;
      }
    </style>
    

    The language in the style tag above is called CSS (which stands for cascading style-sheets). You can read more about it here.

    Just shout if you've any questions on it. Though as a tip, people will be much more responsive if you give details & post an example of what you've already tried to solve the problem yourself — I'm want to do X, I've already tried doing Y which didn't seem to work; it did Z, which I wasn't expected. Good luck! :)

    Cool, thanks a million, how would I go about using css to make all the entries bold also?


  • Registered Users Posts: 1,082 ✭✭✭Feathers


    euser1984 wrote: »
    Cool, thanks a million, how would I go about using css to make all the entries bold also?

    Like this


  • Advertisement
  • Registered Users Posts: 1,657 ✭✭✭komodosp


    <p>
    </br>
    test test test,</br>
    <i style="color:#FACC2E;">Peter & test.</i>
    </p>
    

    If you just want a small piece of text in that colour, use spans...

    e.g. for just Peter in #FACC2E.
    <p>
    </br>
    test test test,</br>
    <i><span style="color: #FACC2E">Peter</span> & test.</i>
    </p>
    

    Bold can be done a couple of ways
    <b>text in bold</b>
    <strong>text in bold</strong>
    <span style="font-weight:bold;">text in bold</span>
    

    Also just one other nit-picking thing, it's
    <br />
    

    not
    </br>
    
    ;)


Advertisement