Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS vertical-align doesn't work properly

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #260441
    onurcan1977
    Participant

    Hi, I’m reading a book about css and this confused me. I’m trying to align my text vertically according to an image but it is aligned to bottom. Here’s my code:

        <title>Untitled Document</title>
    
        #mySpan {
            background-color: red;
            vertical-align: middle;
        }
    
        <p>
            <img src="zemin.jpg" alt="Zemin"> <span id="mySpan">Align Vertically</span>
        </p>
    

    I tried setting width and height properties for all tags however it didn’t work. Can anyone help me?

    #260442
    Beverleyh
    Participant

    Try setting vertical-align on the img instead.

    More info here https://css-tricks.com/almanac/properties/v/vertical-align/

    #260443
    onurcan1977
    Participant

    Hi, thanks for the reply. Yes it works now but I don’t understand why. How does setting position of the image affect separate span?

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.