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 there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Best way to specify text colour?

  • 15-01-2013 5:41pm
    #1
    Registered Users, Registered Users 2 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

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