Reputation: 65
I'm trying to add a space between span and text in React but it seems it behaves differently in JSX? here is the code
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{`${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
As you can see {timeOfDay} which is good night is sticking to the text, what im trying to do is have a space between them, how can i achieve that in React?
Upvotes: 3
Views: 6048
Reputation: 281656
There are multiple ways to add space between elements in JSX
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{`${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
{' '}
return(
<div>
<h1 className="navbar"> <span style={styles}> {timeOfDay} </span>
{` ${firstName} ${lastName}`} It is currently {hours} clock</h1>
</div>
)
Upvotes: 4