Utilizing CSS to Implement a Background Image

Here is where I am looking to upload the image. Ideally, I would like to position my image to the left side of the text related to Food and Travel. You can view the image here.

.block-title h3 {
  color: #151515;
  font-family: 'Montserrat', sans-serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.9px;
  margin-bottom: 24px;
  margin-top: 50px;
  padding-bottom: 13px;
  position: relative;
  text-align: center;
}
<div class="col-lg-12">
  <p>
    <center><img src="#">
      <div class="block-title">
        <h3>Food & Travel</h3>
      </div>
    </center>
  </p>
</div>

Answer №1

To implement this style, simply insert the following CSS code:

div.block-title { display: inline-block; }
<div class="col-lg-12">
  <p>
    <center><img src="#">
      <div class="block-title">
        <h3>Food & Travel</h3>
      </div>
    </center>
  </p>
</div>

Answer №2

If you want to improve your HTML code, consider making the following changes:

<div class="col-lg-12">
    <div class="block-title">
        <img class="image" src="https://image.flaticon.com/icons/png/512/45/45260.png">
        <h3 class="title">Food & Travel</h3>
    </div>
</div>

Here are some tips for optimizing your HTML:

  • Avoid using styling elements like center directly in HTML. Instead, use CSS for styling purposes.
  • Instead of giving styles directly to specific tags (e.g., H3), assign classes to individual elements for better organization and control over styling.

Consider using Flexbox instead of float for layout design. Flexbox offers more flexibility and precision in positioning elements within a container.

To implement Flexbox, add the following CSS to your container:

.block-title {
  display: flex;
  justify-content: center;
  align-items: center;
}

You can also try using display: inline on the H3 element to keep it on the same line as other elements. Adjust the vertical-align property to fine-tune the alignment with the image.

.title {
    display: inline;
(..)
}

.image {
  vertical-align: -25px; //adjust as needed
}

Check out these examples for reference: Flexbox Example | Inline 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

Switching the default image using jQuery upon click event

When I click on the image, I want to see a new image appear for just one second before returning to the default. I tried using setTimeout() function, but even after one second, I still see the same pressed.svg image. Here is my complete code: <html> ...

Expanding the text box in PHP to incorporate new lines

So I have an HTML form where users enter addresses in a text box. The PHP code that processes this input looks like this: $address = $_POST["address"]; echo $address; The output currently comes out as one long line, for example: The Manager, Scotia b ...

Using Javascript to Change Background Color on Button Click

The button press does not result in a change of the background color. What could be causing this issue? var body = document.getElementsByTagName("body"); var bgbutton = doucument.getElementById("bgchange"); bgbutton.onclick = function() { body.style.b ...

What is preventing me from accessing the php page using the AJAX request?

I am encountering an issue with my HTML and PHP code. I am successfully able to receive the mail.value in txt, but facing a problem during the AJAX call as it doesn't even go into the error function. I need assistance in identifying and rectifying th ...

Using attribute value for CSS background-image styling is a handy technique to

In my current situation, the design calls for the use of two different images as background images - one for desktop and another for mobile. These images are uploaded through a CMS, allowing me to retrieve the URLs for both using PHP. Is there a way to pa ...

Tips on modifying classes within specific sections of HTML tables

I attempted to create calendar-like tables, In my script, I am trying to handle events being registered. My goal is to change the classes of cells from 2 to 5 when they are clicked on, and change the cell colors from first to hovered to aqua. For this p ...

Enhance your CSS tables by including margin columns and adding a bottom border to each row

After working on an HTML table element, I decided to include some space between the columns. To achieve this, I used the following css properties: table { border-collapse: separate; border-spacing: 36px 0px; } However, I encountered an issue when attem ...

The translation feature in React does not seem to be functioning properly with SASS

After trying various display settings like flex and block without success, I realized that the transform property was not working as expected. Despite centering elements successfully using other methods, the transform doesn't seem to have any effect o ...

Can someone assist me with updating the image source for it to display correctly within the div element?

I am currently working on a code that displays the URL (data-owner_logo) in my div after indexing JSON. Rather than just displaying the URL string, I want the actual logo image to appear in the div: $('a').on('click', function () { ...

Tips for customizing your MUI slider design

import * as React from "react"; import Box from "@mui/material/Box"; import Slider from "@mui/material/Slider"; function valuetext(value) { return `${value}°C`; } export default function RangeSlider() { const [value, se ...

Deselect all child elements when the parent checkbox is not selected

Creating a page that features multiple checkboxes, some nested and others not. When a particular checkbox is selected, additional options will be displayed underneath it for selection; if unchecked, the child boxes will be hidden. Currently, this functiona ...

Is there a way to incorporate jQuery into SharePoint 2010?

I am encountering an issue with linking my HTML page to our organization's SharePoint 2010 portal. All necessary files (CSS, images, jQuery) are stored in the same document library. While the CSS is functioning properly, I am facing challenges with ge ...

Display the name of the file on the screen

Is there a way to dynamically display the file name in a view instead of hardcoding it? I would appreciate any assistance. Thank you! Here is my code snippet: <li> @if (Model.Picture2 != null) { base2 = Convert.ToBase64String(Model.Pict ...

Locator for finding compound text within a div class using Selenium WebDriver

I am struggling to select a specific button in the UI that shares similarities with other elements. Below is the code snippet for the button in question: <div class="ui green ok inverted button"> <i class="checkmark icon"></i> Yes </d ...

Displaying AJAX Confirmation in a Popup Window

My form is set up to insert data into a database via an AJAX request. Upon successful insertion, the "rentinsert.php" will display a success message on the page that reads "Your order has been placed". However, I would like this success message to appear i ...

A stylish Bootstrap list group featuring large Font Awesome icons

I am working with a Bootstrap 5 List Group element on my webpage. To enhance its visual appeal, I want to include oversized Font Awesome icons. After some styling and using a span tag, I managed to add the icon successfully. However, the issue I am facing ...

Bordering the isotopes

Currently, I am utilizing a plugin that involves the isotope filter library. By setting the width to 33.33%, my list elements are organized into 3 columns. I am trying to specify the middle column to have side borders. However, whenever I click on the filt ...

Looking for assistance in translating HTML code into an XpathQueryString?

While following a tutorial by raywenderlich on how to parse HTML in Xcode, I encountered an issue. I was able to parse his website successfully, but I'm struggling with the concept of Xpathquery. All I need is to extract the data from a table. Below i ...

Mixing without Collections

After initially posting this question yesterday, I realized that I needed to clean up my code before proceeding. However, for my assignment, I am required to create a JavaScript quiz where the questions and answer choices are shuffled every time a user ret ...

Storing an ID field across different domains using HTML and JavaScript: Best Practices

Currently, my web app includes a conversion tracking feature that analyzes whether activity "A" by a website visitor leads to action "B." This feature works effectively when the tracking is contained within a single domain but encounters issues across mul ...