Question

I have the following code:

JS Fiddle


HTML

<a href="#">
    text
    <ins></ins>
</a>

CSS

a {
    display:inline-block;
    height:50px;
    //vertical-align: middle; (does not change anything...)
}
ins {
    display:inline-block;
    height:50px;
    width:50px;
    background:blue;
}

Now, it looks like this:

enter image description here


But it should look like this:

enter image description here


How can I achieve this desired vertical alignment of the text?

Was it helpful?

Solution

Add vertical-align: middle; to ins:

ins {
    display:inline-block;
    height:50px;
    width:50px;
    background:blue;
    vertical-align: middle;
}

JS Fiddle

OTHER TIPS

Get your text in a <span> and style like that

<a href="#">
    <span>text</span>
    <ins></ins>
</a>

span{
    float:left;
    margin-top:15px;
    margin-right:5px;
}

a {
    display:inline-block;
    height:50px;

}
ins {
    display:inline-block;
    height:50px;
    width:50px;
    background:blue;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top