I’ve got an a tag, inside it is a menu text for example “main”.
It sticks to the bottom of the tag, I used display inline block so I could resize it.
How could I make it be in the middle by vertical alignment.
I know I could use an p tag or smth inside the a but I don’t want to clutter, so if you know, please help.
Others have given some options, but if you could post a bit of your code showing how you’ve used the <a>, we might be able to offer some more help. Sometimes you can set the alignment on the parent element instead.
I know I could use an p tag or smth inside the a but I don’t want to clutter,
No, you can’t. Anchors are water, p’s are buckets. Water can’t hold a bucket.
You can use padding like capescafe, which does have the benefit of keeping stuff looking centered even if the text gets long enough to wrap to a new line.
If it’s one word, you can use line-height.
a {
display: inline-block;
min-height: something;
line-height: same as min-height;
}
as an example.
I’m not sure what your css code looks like but to center my text vertically inside the a tag I use padding with equal amounts top and bottom and left and right if you so choose. So like this:
padding:3px 5px;
3px = top and bottom
5px = left and right