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

  • SEARCH
  • Home
  • 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 7443827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:23:39+00:00 2026-05-29T11:23:39+00:00

So the problem is when you have a block of text, and an image

  • 0

So the problem is when you have a block of text, and an image that is slightly too tall that you want to place in-line with the text. For example, a smiley. It will cause the line height of that line of the paragraph to grow, making the block of text look ugly.

I’ve actually already come up with a solution, but it’s messy and I don’t like it… If I wrap the smiley in a relatively-positioned div, and give it an absolute position I get the effect that I’m after:

.holder{display:inline-block;position:relative;width:16px}
.holder img{position:absolute;top:-16px}

<span class="holder"><img src="/smiley.gif" height="16" width="16"></span>

But it adds extra markup. Is there any way to achieve this without adding extra HTML elements – a pure CSS solution (no javascript!)

I wonder if I’m missing some application of overflow/vertical-align/float/display etc?

Many thanks!

  • 1 1 Answer
  • 0 Views
  • 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-29T11:23:40+00:00Added an answer on May 29, 2026 at 11:23 am

    Depending on the desired image position and whether you have a fixed line-height in pixels you could set a maximum height on your image that equals your line-height and set vertical-align: bottom on the image so it fits exactly into your line.

    See this fiddle for an example.

    p {
        line-height: 18px;
    }
    
    p img {
        max-height: 18px;
        vertical-align: bottom;
    }
    
    <p>Some text <img src="/smiley.gif"> more text.</p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a block of text that has a particular image that I want
I have a problem with an image that I am applying a custom jquery
I have this problem that always occurs when I'm using display: inline-block to display
I have a problem with position of a block (div). I am newbie in
I am having a problem using the Unity Application Block, I have created a
I've seen that a few instances of this problem have been raised already. However,
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: We have a web app that calls some web services asynchronously (from the
Problem : I have a hand held device that scans those graphic color barcodes
hi every 1 i have a problem in my jquery i want this adjust

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.