Illustration of CSS schema

I need help aligning the horizontal pictures with their corresponding names below

<div class="imgages">
<img src="rock.png"/><p>Rock</p>
<img src="paper.png"/><p>Paper</p>
<img src="scissors.png" /><p>Scissors</p>
</div>

Answer №1

EXPERIMENT - VIEW DEMO [MODIFIED]

To align pictures horizontally, utilize the CSS property display: inline-block;:

ATTEMPT IT OUT:

div.images img {
    display: inline-block;
}

Utilize HTML5 <figure> and <figcaption> Tags for placing names below images:

For Instance:

<!-- Figure with figcaption -->
<figure>
    <img src="path/to/image.png" alt="Description of image">    
    <figcaption><b>NAME:</b> Caption for the image</figcaption>
</figure>

Output:


NAME: Caption for the image

For more details:

Mozilla MDN - <figure>

IMPLEMENTATION FOR BOTH:

HTML:

<div class="images">
<figure>
    <img src="path/to/image.png" alt="Description of image">    
    <figcaption><b>NAME:</b> Image caption</figcaption>
</figure>
    <figure>
    <img src="path/to/image.png" alt="Description of image">    
    <figcaption><b>NAME:</b> Image caption</figcaption>
</figure>
        <figure>
    <img src="path/to/image.png" alt="Description of image">    
    <figcaption><b>NAME:</b> Image caption</figcaption>
</figure>
</div>

CSS:

.images figure {
    display: inline-block;
}

Answer №2

Strategy that does not rely on the float property.
Utilize the display:inline-block method to arrange the innersections housing the photo in a linear fashion, and insert both the image and text into these inner sections.

EXAMPLE

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

Changing div height with scrolling

I am looking to dynamically increase the height of a div as the user scrolls through the page. You can see the site I am working on here: The specific div that needs its height adjusted is the menu located on the right side of the page. I have developed ...

Tips for showing a public image in-text when pasted on Skype or various social media platforms

As an avid user of Skype, I have discovered that when pasting a link into Skype (using the desktop app) such as a YouTube link, a thumbnail is displayed in the chat. This got me thinking about whether there is a specific class or area in my code, be it CS ...

Incorporating an additional row into a material table

Currently, I have implemented a mat-table with various features including drag and drop functionality and dynamic columns. However, I am facing an issue while trying to add row filters under the table header. I attempted to simply insert a <mat-row> ...

Linking a Wordpress submenu to a specific section of a page

I am utilizing a Wordpress menu to act as the primary navigation for my website. Each main item in this menu is a Page Type that redirects to other existing pages, with one of them containing submenus made up of custom links. These custom links' URLs ...

Unable to Scroll HTML Division

At the moment, I am working on a new website. I have a div where I place images and overlay text on them to describe the images. The issue I am facing is that the text does not scroll even though the scroll bar is visible. This is my HTML: <!DOCTY ...

JavaScript failing to load following PHP header() redirect

I've set up a page that allows users to sign in by filling out a basic form, which then sends the data to a separate PHP script for validation. After the validation process is complete, the PHP script uses the header() function to redirect the user to ...

vertical lines alongside the y-axis in a d3 bar graph

https://jsfiddle.net/betasquirrel/pnyn7vzj/1/ showcases the method for adding horizontal lines along the y axis in this plunkr. I attempted to implement the following CSS code: .axis path, .axis line { fill: none; stroke: #000; } I am lo ...

Utilize CSS styling for elements persistently, even following a postback event triggered by

In my asp.net app, I have multiple hrefs with dynamic Ids that all share the same CssClass called MyClass. I am looking to hide these buttons based on a certain condition. Initially, I used the .ready function: $(document).ready(function() { if(condit ...

Ways to adjust the size of the parent element based on the height of a specific element

I am faced with a situation where I need to identify all elements belonging to a specific class and adjust the padding-bottom of their parent div based on the height of the matched element. For example, consider the following structure: <div class=&ap ...

Experiencing difficulty adjusting the width of a Tumblr post with JavaScript or jQuery?

Calling all coding experts! I've been working on customizing a Tumblr theme, and everything is looking good except for one issue. I'm struggling to adjust the width of photos on a permalink (post) page. Check out this link: You'll notice t ...

Prevent div from moving upward using CSS

Whenever I use the search box, a dropdown list of suggestions appears. However, the searchbox div element keeps moving both up and down. How can I prevent the div from moving upwards? The code snippet below shows a hardcoded unordered list of names for s ...

Display an error alert when a specific condition occurs

My page has a code snippet that triggers an error alert when loaded: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["message"] == "noemployees") ...

Upon page load, a dazzling SVG file will flicker before being adorned with CSS styles

I'm experiencing an issue with an SVG arrow icon on my webpage that flashes quickly across the entire screen upon page load before settling into its proper size and placement. I've tried using CSS to initially hide the icon and then reveal it aft ...

I'm having trouble getting my jQuery click handler to work

Here is the HTML content within my Sharepoint 2010 Web Part project: <html> <h1>Travel Form Assistance</h1> <div id="preTravel" name="preTravel"> <h2>Pre Travel</h2> <img id="imgPreTravel" name="imgPreTra ...

Here's a solution for fixing this layout issue: The alignment of the table titles with the content needs to be adjusted, and the content in each row should

I am attempting to create a layout that features a type column on the left that takes up more width compared to the other two items on the right. This is because the type and description may be lengthy. Additionally, I want the type and description of each ...

Stopped due to an error: TypeError - document.getElementById(...) is not defined

Currently, I am working on developing a commenting system. Everything seems to be functioning well as long as there is at least one existing comment. However, if there are no comments present and an attempt is made to create one, an error message pops up d ...

Ways to retrieve a specific item from a constantly changing knockout observableArray without employing a foreach loop

Why can I only access one property ('member_A') of an Element in an observableArray using an HTML <input>? I am attempting to add a new object of type abc() to the observableArray "list_of_abc" when the button "ADD To List of abc" is click ...

Having trouble with the Bootstrap dropdown? The unordered list isn't dropping down as expected. What could be the issue?

I am facing an issue with two dropdowns in my template. Both of them are not functioning properly, one with Thymeleaf attributes and the other without. I have not attempted to change the CSS properties as they were working fine before but now they do not ...

Dynamic Filtering with jQuery List

I'm attempting to create a dynamic filter list on keypress event. For example, if I type "It" into the input field, the elements that do not match this value will be hidden. I'm unsure if the code structure I have implemented below effectively ac ...

Is there a way to customize the hover effect on this navigation link in Bootstrap that includes a span and an icon from Bootstrap?

<li class="nav-item mt-3"> <a href="#" class="nav-link px-2 d-flex justify-content-start align-items-center"> <i class="nav-icon bi bi-calculator-fill fs-4"></i> ...