# How to give each letter a different color - Learning React?

**URL:** https://forum.kirupa.com/t/how-to-give-each-letter-a-different-color-learning-react/655953
**Category:** web dev
**Created:** [January 2, 2023, 9:22pm UTC](https://forum.kirupa.com/t/how-to-give-each-letter-a-different-color-learning-react/655953 "2023-01-02T21:22:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ettenytten](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ettenytten/32/20047_2.png) [@Ettenytten](https://forum.kirupa.com/u/Ettenytten)
#### Post date: [January 2, 2023, 9:22pm UTC](https://forum.kirupa.com/t/how-to-give-each-letter-a-different-color-learning-react/655953/1 "2023-01-02T21:22:55Z")

</div>

Help pls. I wanted to attain that results from the book Learning REACT as a beginner. And I follow all procedure from the book, but I didn’t manage to make the results that will create all the 5 letters to have different colors on each background.

```auto
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Styling in React</title>
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>

    <style>
      #container {
        padding: 50px;
        background-color: #fff;
      }

      .letter {
        padding: 10px;
        margin: 10px;
        background-color: #ffde00;
        color: #333;
        display: inline-block;
        font-family: monospace;
        font-size: 32px;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <script type="text/babel">
      var destination = document.querySelector("#container");

      class Letter extends React.Component {
        render() {
         var letterStyle = {
            padding: 10,
            margin: 10,
            backgroundColor: "#ffde00",
            color: "#333",
            display: "inline-block",
            fontFamily: "monospace",
            fontSize: 32,
            textAlign: "center"
         };
          
         return (
            <div>
                {this.props.children}
            </div>
         );
        }
      }

      ReactDOM.render(
        <div>
          <Letter>A</Letter>
          <Letter>B</Letter>
          <Letter>I</Letter>
          <Letter>O</Letter>
          <Letter>U</Letter>
        </div>,
        destination
      );
    </script>
  </body>
</html>

```

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [January 2, 2023, 9:34pm UTC](https://forum.kirupa.com/t/how-to-give-each-letter-a-different-color-learning-react/655953/2 "2023-01-02T21:34:02Z")

</div>

Hi @Ettenytten - welcome to the forums! Right now, you have all of your letters hard-coded to be `#ffde00` as defined in `letterStyle`:

`backgroundColor: "#ffde00",`

In the book, you’ll see later in the chapter where we pass in a prop to the `Letter` component that defines the color. We then read that `prop` and assign the color value to our `letterStyle` object.

Have you tried that code and aren’t able to see the results? If so, please post the code from that section and we can help you out further! 🙂

Cheers,  
Kirupa
