Placing an emblem after the header wording

Within my h1 tag, I have a header text that I would like to display alongside a small icon on the right side.

The length of the text can vary, which presents a challenge in alignment.

I attempted to use a background image with no repeat, but it ends up positioned too far to the edge of the div element.

Is there a way to ensure that the background image always lines up at the end of the text? Perhaps using a different approach than the one I previously tried?

h1 {
background-image:url(images/quotemarks.png);
background-repeat:no-repeat;
background-position:right;

Answer №1

Give this a shot:

p:before {
    content:url(img/quotes.png);
}

EXAMPLE

Answer №2

If I follow correctly, by including a span element with an image inside the h1 tag along with some CSS styling, you should achieve the desired outcome... possibly...

HTML:

<h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<span class="end"><img src='some icon.png'/></span>
</h1>

CSS:

h1{
    display:inline-block;position:relative; padding-right:2em
}
.end{
    position:absolute; right:0; bottom:0; width:2em
}

View the live demonstration here: http://jsfiddle.net/aXjzg/2/

For more insights, visit: Place 'floating' contents at the bottom right of a paragraph of text

Answer №3

If you want your heading to display inline and have some extra padding on the right side to contain a background image, you can try something similar to this:

<style>
    .h1-with-image {
    display: inline-block;
    padding: 0 15px 0 0;
    background: url('/image.jpg') no-repeat top right;
        }
</style>

<h1 class="h1-with-image">Heading</h1>

Check out an example here: 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

The dialog box in CSS is extending too far down past the bottom of the screen, making it impossible to scroll and click on the buttons located

I am currently working on creating a dialog box with a text area using material UI. Unfortunately, when I input a significant amount of text, the dialog box ends up extending beyond the screen, making it impossible to scroll down to access the buttons. &l ...

Implementing Ajax to display autocomplete suggestions in an HTML table

I've been working on implementing an ajax auto complete function into my HTML code. My goal is to display the results from the auto complete function in a table on the html page. Although the auto complete function is working and I can see the drop do ...

How should attributes be passed to the li element properly?

I am trying to transfer values from the database to the <li> tag. Can someone confirm if the approach below is valid and the proper way to do it? <li id='$current_row["RA_SUB_ID"]' component_name='$current_row["RA_SUB_NAME"]' ...

How can I create a box-shaped outline using Three.js?

As someone new to threejs, I have been trying to figure out how to render a transparent box around a symbol in my canvas. The box should only display a border and the width of this border should be customizable. Currently, I am using wireframe to create a ...

Find the HTML elements within an XDocument that need to be replaced and converted into Json format

XML contains HTML tags that need to be removed using XDocument. Is there a way to identify nodes with HTML tags and replace them throughout the entire document? Below is a sample of the XML structure: <?xml version="1.0" encoding="utf-8"?> <myFie ...

Adjust the dimensions of a button in Jquery Mobile using a designated class

I am in the process of creating a Mobile App using Jquery Mobile, I'm aiming for a result like this: Unfortunately, what I end up with is this: I prefer not to utilize .ui-btn in my CSS, as I have already specified custom-btn. Here's the code s ...

Removing styling from a table header and specific table data cells with CSS

I am trying to create an HTML table where I only want to select cells that are not part of the thead section and do not have a specific class. I am having trouble with the selector for this particular case. table :not(thead):not(.cell-class) { backgro ...

Associate the ng-model with ng-options value and label

I'm currently using ng-options to create a select tag that displays location options. The labels represent the location names, while the values indicate the corresponding location ID as stored in the database. In addition to binding the value (locati ...

Creating a custom navigation bar that elegantly fades away with a smooth animation as you scroll down the page is a must-have

How can I create a navigation bar that disappears when scrolling, with a smooth animation? This is the progress I have made so far. HTML: <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="css/style.css" type="tex ...

Is it possible to dynamically adjust the width of table columns using CSS/LESS on a per-column basis?

In this scenario, the table's column width is determined by the number of columns present. For example, if there are 4 columns in the table, each column's width would be set to a maximum of 25% of the table's overall width. With 3 columns, t ...

Is there a way to adjust the positioning of an image within a <div> element?

I'm attempting to vertically align an image within a horizontal menu bar. My goal is to adjust the padding/margin of the image using inline CSS. However, I've noticed that when I add margin-top or padding-top, it affects the positioning of all m ...

Rails: How come my personalized stylesheet isn't taking priority over the font family?

I have included the Skeleton boilerplate css in my application from this source. It can be found within the directory app/assets/stylesheets. app/assets/stylesheets ├── application.css ├── custom.scss ├── normalize.css └── skeleton ...

How can the parent div be made transparent without affecting the child div's visibility?

When applying opacity to a parent div, I noticed that it also affects the child div. My intention is to only apply opacity to the parent div. I have set up separate divs for this purpose. <div id="container" style={{backgroundImage:"url('/images ...

The window.onload function is ineffective when implemented on a mail client

Within my original webpage, there is a script that I have created: <script> var marcoemail="aaaaaa"; function pippo(){ document.getElementById("marcoemailid").innerHTML=marcoemail; } window.onload = pippo; </script> The issue a ...

Creating a responsive layout with two nested div elements inside a parent div, all styled

I'm currently facing an issue with using padding in my CSS to make the two divs inside a parent div responsive at 50% each. However, when combined, they exceed 100%. I suspect this is due to the padding, but I'm unsure how to resolve it. .column ...

Tips on effectively managing sibling nodes with unique behavior on the initial one

Greetings and thank you for taking the time to read and assist. While I have gained a good understanding of how XSLT 1.0 processes XML, there is one issue that continues to baffle me. The problem arises from having a template that matches the first node ...

The float:left property within a div is not behaving as anticipated

I am having trouble positioning my second div. In order to have 70% of my website for posts and 30% for a small text display, I created a new div. I believe the correct way to position it is by using "float: left" so that the div goes under the banner whe ...

Exploring WordPress's Query Page with Posts

My current code successfully pulls posts from a specified category, but I am struggling to also include pages in the output. I have tried various methods, but haven't been able to pull in both posts and pages at the same time. HTML/PHP <?php quer ...

Is there a way to horizontally center a content container in Flutter similar to a "max-width" container in CSS?

How can I create a centered content box like this in Flutter?: .content-box { margin-left: auto; margin-right: auto; width: 100%; max-width: 600px; background-color: blue; height: 100vh; } <div class="content-box"> Cont ...

What are the steps for incorporating information into a designated PhpMyAdmin account?

Currently, I am experimenting with HTML and Php. The website is quite simple at the moment and lacks adequate security measures. My objective is to update a specific user's competition field in the users table located within the authentication folder ...