Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1098163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:32:19+00:00 2026-05-17T00:32:19+00:00

I have the following code: <html> <head> <style type=text/css> #test img {vertical-align: middle;} div#test

  • 0

I have the following code:

<html>
<head>
<style type="text/css">
#test img {vertical-align: middle;}


div#test {
border: 1px solid green;
height: 150px;
line-height: 150px;
text-align: center;
color: white
}
</style>
</head>

<body>

<div id="test">t<img class="bottom" src="http://www.w3schools.com/css/w3schools_logo.gif" alt="W3Schools" width="270" height="50" /></div>
</body>
</html>

If I remove the t after the the image, then it doesn’t align vertically in the center (I test it in firefox). As it is now it aligns, so I could change the color of the text to be the same as the background or the other way was to put an inline style and set it as a background.

Is there any other way to align vertically an image with CSS? I found these ways to be a bit of a hack.
How would that worked in CSS3?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:32:20+00:00Added an answer on May 17, 2026 at 12:32 am

    The reason that the t makes a diffence, is because images are treated differently if they are the only element, or if they are part of a text.

    How images are treated as single elements depend on the rendering mode of the page. In the beginning images as single elements were treated as block elements, and that behaviour is retained in certain sitations to be backwards compatible. You should put a proper doctype on the page, so that it’s not rendered in quirks mode, if it doesn’t solve your problem, at least it will make it behave more consistently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code <html> <head> <title>Test</title> <style type=text/css> <!-- body,td,th { color:
I have the following code: <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8> <title></title> <style type=text/css> body
I have the following code <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <title>Untitled Document</title>
I have the following code: <HTML> <head> <style>div{border:dashed 1px silver}</style> </head> <BODY style=background: #fff;>
I have the following html and css code: <!DOCTYPE HTML> <html> <head> </head> <body>
I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input
The Problem I have the following code: <html> <head> <style id=ID_Style> .myStyle { color
I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>
I have the following HTML Code <%@ Page Language=C# %> <html> <head> <title></title> </head>
I have the following code <xsl:result-document href=output1/output3/index.html format=html> <html> <head> <SCRIPT LANGUAGE=JavaScript> function getParams()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.