Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align multi-line text after icon

Tags:

html

css

In a table with indentation (tree data), i need to align second line with the first line.

Notice, text "Tail" doesn't align with "Long"

enter image description here

Created a similar example here

div{
  width:400px;
}
<div>
  <a href="">ICon:</a>
  <span>This is my fight song. Take back my life song. Prove I'm alright song. My power's turned on
Starting right now I'll be strong</span>    
</div>
like image 430
Jhankar Mahbub Avatar asked Dec 24 '22 10:12

Jhankar Mahbub


1 Answers

You can do this with display: table; and display: table-cell;

div{
  width:400px;
  border: 1px solid black;
  display: table;
  padding: 10px;
}

a, span {
  display: table-cell;
  vertical-align: top;
}
<div>
  <a href="">ICon:</a>
  <span>This is my fight song. Take back my life song. Prove I'm alright song. My power's turned on
Starting right now I'll be strong</span>    
</div>
like image 72
Nenad Vracar Avatar answered Dec 27 '22 02:12

Nenad Vracar