1

I just wants to display a font awesome icon and text in a line:

<th>
 <span>
  <a>
   <i style="color:green;font-size:22px;" class="fa fa-plus-circle" aria-hidden="true"></i>
  </a>
 </span>
 <span> Add Task</span>
</th>

It's working but the problem is => enter image description here

If you take a look at above pic then you can see the text is not on the middle of the icon. I tried to put some margin there but it's not working. Can anybody help me?

Tree
  • 254
  • 1
  • 14
nayan chowdhury
  • 283
  • 1
  • 9
  • 28

2 Answers2

2

Target the element containing the font-awesome icon. Set position as relative and adjust top value;

a {
  text-decoration: none;
  font-family: Arial;
  color: #333;
}


/*Example 1*/

i {
  color: green;
  vertical-align: sub;
  font-size: 50px;
}

i::before {
  font-size: 30px;
}


/*Example 2*/

span {
  color: green;
  font-size: 50px;
  position: relative;
  top: 4px;
}

span::before {
  font-size: 30px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<!--Example 1-->

<a href="#">
  <i class="fa fa-plus-circle" aria-hidden="true"></i> Add Task
</a>

<br>

<!--Example 2-->

<a href="#">
  <span class="fa fa-plus-circle" aria-hidden="true"></span> Add Project
</a>

Example Code Pen: https://codepen.io/Omi236/pen/KqbQoO?editors=1100

Robert Williams
  • 1,370
  • 1
  • 17
  • 38
1

In your case, you just need to use font size property at parent level.

Working example

<!DOCTYPE html>
<html>
<head>
<title>Font Awesome Icons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>

<a style="font-size:16px;"><i class="fa fa-plus-circle"style="color:green;"></i><b> Add New</b></a>
</body>
</html>
Billu
  • 2,733
  • 26
  • 47