Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8932311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:18:07+00:00 2026-06-15T09:18:07+00:00

My CSS: h1 { background-color: #f7953d; color: #FFF; width: 100%; padding: 6px 0 6px

  • 0

My CSS:

h1 {
    background-color: #f7953d;
    color: #FFF;
    width: 100%;
    padding: 6px 0 6px 10px;
    margin-bottom: 10px;
}

My HTML

<h1>Hello World</h1>

The background color is always stretched to 100% of the screen. How do I make the background color stop after “World” in the h1 tag, and not go all the way to the end of the screen?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:18:08+00:00Added an answer on June 15, 2026 at 9:18 am

    H1 is by default a block element and so will span the full width of its parent container you want to make it an inline element (much like a span) in order for it to only be as wide as its contents.

    There are 2 possible solutions dependent on your compatability needs

    display:inline;
    

    will achieve the effect your after however it does mean that whatever follows your H1 could appear on the same line.

    display:inline-block;
    

    Has the effect your after while still forcing anything following it to appear below the H1 the only downside to this is it can throw up some issues in IE<8 see quirksmode for more details

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function toggle(){ $(#tempc).toggle( function () { $(#tempc).animate({width: 255, height: 220}, 1000); $(#tempc).html(); $(#tempc).css(background-color, transparent);
$(this).parent().parent() .children(this.attr(tagName).toLowerCase()) .css(background-color, yellow); xpath: /html/body/div/table/tr/td/b/a $(this).tagName is Anchor <a> the problem with this
I use the following jquery statements, $(.resultsdiv:odd).css(background-color, #fff); $(.resultsdiv:even).css(background-color, #EFF1F1); $('.resultsdiv').hover(function() { $(this).css('background-color', '#f4f2f2');
CSS code body { background-attachment: scroll; background-clip: border-box; background-color: #ececec; background-image: none; background-origin: padding-box;
The page has the following CSS: input[type=text] { display: inline; padding: 7px; background-color: #f6f6f6;
I am doing slideToggle as follows: $(document).ready(function(){ $(#show_morecats).click(function(){ $(#morecats).slideToggle(slow); $(#show_morecats).css(background-color,#399C05); }); }); HTML <a
I have this js code: $(.main-vervolg .right .bottom .panes table.grey tbody tr:odd).css(background-color, #f8f8f8); And
Let's say I have this $(.a).animate( {left:100%}, {duration:50000, complete:function(){ $(.a).css(background-color,black); }} ); $(.b).mouseover(function(){ $(.a).stop();
I have this JQuery code jQuery(\'.tpcoupon-reveal\').click( function() { jQuery(\'.inner-code\').css(\'background-color\',\'#FFF\'); jQuery(\'.inner-code\').text(jQuery(this).attr(\'caption\')); visitstore = jQuery(this).attr(\'url\'); window.open(visitstore);
I'm using this code with jquery $(.tab).css({'background-color': '#f3f6ed', 'border': '4px solid rgba(0,0,0,0.1)', 'border-bottom': 'none'});

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.