Position the image right beside the <h> heading

Just recently, I embarked on the journey of learning HTML and CSS. However, I have encountered a challenge:

#referenzen{
        width: 100%;
        padding: 25px;
    
    }

    #referenzen h1, h2, h3, h4, h5, h6{
        margin-bottom: 0;
    }

    #referenzen p{
        padding-right: 25px;
        font-size: 18px;
    }

    #referenzen img{
        height: 50px;
        width: 50px;
        float: left;
    }
<div id="wrapper">
    <div id="referenzen">
        <img src="../Bilder/info.png">
        <h1>Unsere Firmengeschichte</h1>
        <br>
        <p>Die Firma Fair-Bau GmbH wurde im April 2010 gegründet und betätigt sich in den Sparten ausführende Baumeisterarbeiten, Vollwärmeschutzarbeiten, Verputzarbeiten sowie dem Handel mit Baustoffen.
            Der Betrieb beschäftigt 15- 20 Mitarbeiter.</p>
    </div>

Is there a way to directly link the image to the <h1> tag so they appear side by side?

Here is how the page looks currently: https://i.sstatic.net/Zq0gJ.jpg

Your help would be greatly appreciated!

Answer №1

There are a couple of approaches I would consider:

  • Using HTML: You have the option to place the <img> tag inside your <h1></h1> tag
  • With CSS: You can designate both h1 and img to have a display: inline-block property

I personally prefer the first method.

Clarification for better comprehension:

The <h1>...<h6> tags typically display as block elements by default, occupying 100% width within their parent container. By changing them to inline-block, it alters the width to be either a specified value or adjusts based on the content size if no fixed width is defined.

Answer №2

To add space above the image, simply use margin-top: 15px.

#references {
  width: 100%;
  padding: 25px;
}
#references h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: 0;
}
#references p {
  padding-right: 25px;
  font-size: 18px;
}
#references img {
  height: 50px;
  width: 50px;
  float: left;
  margin-top: 15px;
}
<div id="wrapper">
  <div id="references">
    <img src="http://vignette2.wikia.nocookie.net/dccu/images/b/bc/Icon-Wikipedia.png/revision/latest?cb=20160324075444">
    <h1>Our Company History</h1>
    <br>
    <p>Fair-Bau GmbH was established in April 2010 and specializes in executing structural building works, thermal insulation works, plastering works, and trading in construction materials. The company employs 15-20 workers.</p>
  </div>

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

Parsing Images Using JSON and Ajax

I am facing an issue with extracting an image from a JSON file located at this link using jQuery/ajax and inserting it into a div. Despite my efforts, I am struggling to achieve this task due to being new to this field. Your assistance is greatly apprecia ...

Photo frame edge

I am in the process of creating a basic website using HTML and CSS. My current task involves taking an image and using it as a page border. Unfortunately, I am unable to share my progress at this moment because I am unsure of where to begin. I understand ...

Utilizing a live input from an HTML form in App-Script

I am completely new to the world of HTML and App-Script. My goal is to create a dynamic list of options from a Google Sheet that will populate a listbox in my HTML code. When a user selects an option from the listbox and clicks submit, I want that value to ...

Designing a feature to toggle between displaying and hiding different content sections

Can you make it so that when I click on the toggle checkbox, it will hide/show one of the two div elements? The CSS provided below is for styling purposes only; and my HTML structure for the DIV elements cannot be altered. input[type="checkbox"] { ...

Show live updates in the input field

I'm struggling to get an input's results to update in real time within another disabled input field. Here is the code I'm working with: var inputBox = document.getElementById('input'); inputBox.onkeyup = function(){ document. ...

Similar title across various categories, retrieve link, Beautiful Soup in Python

Looking for a way to extract URLs from specific HTML elements: <div class="posts-container col-md-6" <ul class="emb-embassies-list" <a class="entry-title" href="commonlink.com" <ul class="emb-embassies-list" <a class="entry- ...

Using a slider in Cordova application

Currently, I am in the process of developing an app using Cordova. However, I have encountered an issue with the slider feature. HTML <body> <div id="slider"> <div id="custom-handle" class="ui-slider-handle"></div> </di ...

Placing a list item at the beginning of an unordered list in EJS with MongoDB and Node.js using Express

What I've done: I already have knowledge on how to add an LI to UL, but it always goes to the bottom. What I'm trying to achieve: Add an LI to the top so that when my div.todos-wrapper (which has y-oveflow: hidden) hides overflow, the todos you a ...

Is there a way to align the image next to the form and ensure they are both the same size?

I've been struggling to resize the image to match the form size, but I can't seem to get it right. Can anyone provide me with some guidance on this issue? I have obtained this contact form from a website that I plan to modify slightly, but I need ...

Attaching an SVG chart to a node causes it to malfunction, indicating a fundamental element is absent

I've been attempting to display a d3fc graph on an svg node within my react.js component and return the entire structure. However, it crashes when I try to apply .datum(my_data) to the d3 selection. I suspect that I'm overlooking something fundam ...

Is there a way to automatically increase the width of a textarea?

Is there a way to automatically adjust the width of a textarea? I know how to make it grow in height, but I haven't come across a method to only increase the width. To provide a visual example, I'm looking for something similar to how iMessage e ...

Utilizing nested flex containers with overflow-x property

I'm looking to set up a layout with 2 columns side by side. The first column should have a fixed width of 200px, while the second column should take up the remaining space on the screen. Additionally, I want the content in the second column to auto-sc ...

Having difficulty retrieving the initial selection value

Despite receiving all other values, I am unable to retrieve the event.everyday value. Can you please help me identify what I might be doing incorrectly? Situation - Choose Every day from the dropdown menu. Click on the "click it" button and review the ...

Utilize a dynamic URL within the HTML audio element

Currently, I am working with the use of the audio tag in HTML and AngularJS. I need to specify the source of the audio file I want to play, as shown below. <audio src="http://localhost/audio/221122/play/212223.mp3" audio player controls p ...

Obtain the Week Input's Value

Is there a way to store the value of a week input in a variable and then display it in a span? I attempted the following code: <input type="week" name="week" id="week-selector"> <span id="kalenderwoche"> ...

ideas for adding a button in the midst of several rows

Trying to dynamically add two buttons after the first image in each row of a table using a script. The table is retrieved from a server, and the script should automatically insert the buttons. <html> <body> <tr style="background:#EEE;li ...

Trouble with webpage design persists following recent modifications

Today, I decided to make some alterations on the header.php file of my WordPress website in order to tweak the flag icons displayed at the top of the page. However, when I refreshed the page, everything looked completely chaotic. Even after undoing all th ...

Click here to open in a new tab and experience the ever-changing dynamic

Imagine a scenario where a property site displays the main viewed property ad at the top, with smaller ads in square divs below. When a user clicks on one of the smaller ads, it dynamically swaps places with the main ad thanks to JavaScript. All ad data is ...

Having Trouble with the Bootstrap Responsive Menu Button Not Working

I'm struggling with the Bootstrap menu I created, as it's not collapsing or animating. Everything seems to be working fine except for the button that isn't functioning. <nav class="navbar navbar-expand-lg navbar-light bg-dark alb ...

React does not play well with Bootstrap's JavaScript and may cause it to not function or load properly

Initially, I set up a simple react application by running the command: npx create-react-app appnamehere Following that, I proceeded to install Bootstrap (trying both versions 4 and 5) with the command: npm install bootstrap After this, I included them in ...