Make sure to align images and comments seamlessly on your website just like in the comment section of YouTube

Looking for help aligning an image and two spans in one row

        <img src="../images/profile/profile.png" class="img" />
        <span class="name">First Name</span>
        <span class="comment">
            This is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently this is end of count.
        </span>

Fiddle http://fiddle.jshell.net/m3qyhoab/

I have tried changing the image and span display properties to block, etc., but still haven't been able to get them aligned properly

Answer №1

Consider utilizing a table for organization:

<table>
        <tr>
            <td><img src="http://i450.photobucket.com/albums/qq229/veraqueen/80X80-1.jpg" class="img" /></td>
            <td><span class="name">First Name</span></td>
            <td> <span class="comment">
                This is just filler text used in the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also made the leap into electronic typesetting, remaining essentially unchanged. It became popular in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently this is the end.
            </span></td>
        </tr>
</table>

Answer №3

Learn CSS

.container {
    max-width:800px;
    margin:30px auto;
    background-color:#ccc;
    display:inline-block;
}
.image {
    width:80px;
    float:left;
    margin-right:15px
}
.title {
    float:left;
    width:80px;
}
.description {
    float:left;
    width:600px;
}

Check out the DEMO here

To ensure smooth functioning, make sure to specify widths for each class that uses Float property

Answer №4

To ensure your image occupies vertical space while maintaining alignment of the name and comment to its right, you can try utilizing this method.

It is recommended to avoid using <table>. For a more organized approach, you may also utilize bootstrap.

Here's to successful formatting!

Answer №5

Fidler

.container {
    max-width:800px;
    margin:30px auto;
    background-color:#ccc;
}
.image {
    width:80px;
    float:left;
    margin-right:15px
}
.title {
    float:left;
    width:100px;
}
.description {
    float:left;
    width:605px;
}

Some observations I made :

  • Remember to end each CSS property with a semicolor (;)
  • Avoid mixing relative units like % with absolute units like pixels.
  • Try implementing the suggested code for better results.

p.s. Adjust the Result window positioning if it wraps onto multiple lines.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to make a letter stretch all the way down the paper?

As I'm creating a table of contents for my website, I was inspired by an interesting design idea that I came across: I am particularly drawn to how the T extends down and each section is numbered with the title wrapped around it. How can I achieve th ...

The color of hyperlinks in firefox varies based on the specific URL being visited

I am a beginner in the world of html and css. I have two links placed consecutively. In my css file, I have defined classes for a:link and a:hover. However, I noticed that the second link is displaying a purple color instead of silver. Both links correctly ...

Php Error 404 occurs upon attempting to redirect from the main landing page

I have been encountering an issue while trying to add links to different pages of my website. Whenever I click on the link, it displays a "404 Page Not Found" error message. Objective: My main goal is to create links from my home page, index.php, to other ...

Navigating tables with Selenium WebDriver

I am struggling to locate and interact with a specific element in a table using Selenium WebDriver. The issue is that the table IDs are constantly changing, making it difficult for me to click on the desired element. For instance, consider the following t ...

Crafting a dynamic inline search form with Bootstrap

My goal is to replicate the design in this image: This is my current progress: ...

Make sure link opens in the same window/tab

Currently, I am utilizing the Open Link in Same Tab extension on Google Chrome. This extension can be found here. The purpose of this extension is to ensure that all links open in the same window/tab, which is necessary for touch screen kiosk left/right s ...

What could be the reason for the lack of styling on the select element when using PaperProps in the MenuProps of my Select component?

I've been struggling to remove the white padding in this select box for a while now. I've tried countless variations and places to tweak the CSS with no success. Any suggestions on how to make it disappear? The project is using MUI 5, and I even ...

Attempting to choose everything with the exception of a singular element using the not() function in Jquery

Within the mosaic (div #mosaique) are various div elements. My goal is to make it so that when I click on a specific div, like #langages or #libraries, the other divs become opaque while the selected div undergoes a size change (which works correctly in t ...

Forms for uploading and submitting multiple files

On my single page, I have several file upload forms that are generated in a loop. The issue is that the first file upload control works fine, but the others do not. <div> <form action="/docs/1046/UploadDocument?Id=1046&amp;propertyTypeId ...

Adjusting image alignment and formatting long text with CSS in Firefox

I'm attempting to float an image and text within a paragraph, but encountering an issue when the text is long and in one line. The display appears fine in Chrome, but not in Mozilla Firefox. You can view the problem here: In Chrome, it looks like thi ...

The CSS Bootstrap 4 class 'input-group-append' is not functioning properly. Just recently, the styles were displaying correctly

My web application using AngularJS 1.7.8, jQuery 3.3.1, Bootstrap 4.3.1, and various other CSS and JS libraries worked seamlessly last week. However, today I noticed an issue with the button visualization. To Replicate: Visit openskymap.org to see my d ...

Having trouble with the flexbox flex-direction: column property not functioning properly with the textarea element in Firefox?

Inconsistencies between Chrome and Firefox have been noticed in the following example. While the footer height is set to height:40px and appears fine in Chrome, it seems smaller in Firefox, around 35px. Any specific reasons for this difference? Link to t ...

Issue with the div elements not aligning next to each other

I am facing an issue with my code in blade.php where I need to display images. The ideal layout would be to have the images stacked side by side within a div element, but unfortunately, it's not working as expected. I have tried using flex, bootstrap ...

Is there a way to turn off vue.js transitions specifically for testing purposes?

I'm utilizing a vue.js component with the <transition> element for show/hide animations. However, I want to disable the animation for faster testing. How can I achieve this? The solution proposed is * { transition: none !important } in this lin ...

Adding a semi-transparent layer to cover half of the canvas while still allowing the canvas to be visible

I'm struggling with overlaying a div on top of a canvas while keeping the canvas visible. Currently, I can only get the div to cover the canvas and hide it. If anyone has an example to share, that would be greatly appreciated. var canvas = document ...

Issues with PHP Mail Forms not functioning as intended

I've been struggling for hours trying to figure this out. I'm new to PHP mail form coding and any assistance would be greatly appreciated! Below are two images: one of the HTML code and one of the PHP code. It seems like a simple setup, but even ...

Automatic Expansion Feature for HTML Tables

http://jsfiddle.net/bzL7p87k/ In my table, placeholders are filled with special words. However, what happens when I have more than 4 rows? For instance, if there are 21 placeholders for 21 rows? What I mean is this: I only have one row with a placeholder ...

Struggling to align content vertically within an article and in need of some guidance

Still struggling with vertical alignment of content within an article. I've tried using tables and the vertical-align property but can't seem to make it work. Any suggestions for centering the content responsively on the right-hand side? The lef ...

Tips for maintaining knowledge after redirecting to a new page

Building an app using Ionic 4 where I need to display vouchers from a database as images. Each image should act as a link to a details page showing more information about that specific voucher. However, I am struggling to figure out how to keep track of th ...

How can I convert a JSON template to HTML using AngularJS?

As someone who is just starting out with AngularJS, I am facing an issue where the HTML tags in a JSON file are not being encoded when rendered in HTML using AngularJS. Is there a specific method in AngularJS that can help with this? This is what my HTML ...