Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Best way to specify text colour?

  • 15-01-2013 06:41PM
    #1
    Registered Users, Registered Users 2 Posts: 1,995 ✭✭✭


    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

  • Registered Users, Registered Users 2 Posts: 2,559 ✭✭✭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, Registered Users 2 Posts: 1,995 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 1,995 ✭✭✭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, Registered Users 2 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, Registered Users 2 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