Having trouble getting my <p> tag in the title section to align perfectly in the center

Could you please help me understand why the <p> tag is not center aligning properly in my code? The alignment seems a bit off from what I expected. Below is the section of CSS that I believe is related to this issue, although I did not originally write it.

 #hero-area2 .contents {
    padding: 200px 0 130px;
  }
  
  #hero-area2 .contents h1 {
    color: rgb(38, 211, 125);
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 25px;
  }
  
  #hero-area2 .contents p {
    font-size: 14px;
    color: rgb(38, 211, 125);
    font-weight: 400;
    line-height: 30px;
    letter-spacing: 0.5px;
    text-align: center;
  }
  
  #hero-area2 .contents .btn {
    margin: 25px 25px 0px 0px;
    text-transform: uppercase;
  }
   <div class="container">
      <div class="row justify-content-md-center">
        <div class="col-md-10">
          <div class="contents text-center">
            <h1 class="wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="0.3s">Kuvumela Amandla</h1>
            <p class="lead  wow fadeIn" data-wow-duration="1000ms" data-wow-delay="400ms">Our Service Offering</p>
            <a href="contact.html" class="btn btn-common wow fadeInUp" data-wow-duration="1000ms"
              data-wow-delay="400ms">CONTACT US</a>
          </div>
        </div>
      </div>
    </div>
https://i.sstatic.net/Cj5Zr.jpg

Answer №1

It appears that the issue may lie within the use of the p tag combined with bootstrap's column system. By utilizing a .col-md-10 without centering it, the text may not display as intended. Consider adding an offset to achieve proper alignment, such as using .col-md-10.offset-md-1 for better results.

Answer №2

I'm not quite clear on your issue, but I experimented with some CSS code:

display: grid;
align-items: center;
justify-content: center;
background-color: blue;
height: 100px;
width: 200px;

Apologies, I've only been learning CSS for about a month.

Answer №3

 #hero-area2 .contents {
    padding: 200px 0 130px;
  }
  
  #hero-area2 .contents h1 {
    color: rgb(38, 211, 125);
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 25px;
  }
  
  #hero-area2 .contents p {
    font-size: 14px;
    color: rgb(38, 211, 125);
    font-weight: 400;
    line-height: 30px;
    letter-spacing: 0.5px;
    text-align: center;
  }
.kon{
       text-align: center;
}
  
  #hero-area2 .contents .btn {
    margin: 25px 25px 0px 0px;
    text-transform: uppercase;
  }
   <div class="container">
      <div class="row justify-content-md-center">
        <div class="col-md-10">
          <div class="contents text-center">
            <h1 class="wow fadeInDown" data-wow-duration="1000ms" data-wow-delay="0.3s">Empower Your Potential</h1>
            <p class="kon" data-wow-duration="1000ms" data-wow-delay="400ms">Discover Our Services</p>
            <a href="contact.html" class="btn btn-common wow fadeInUp" data-wow-duration="1000ms"
              data-wow-delay="400ms">GET IN TOUCH</a>
          </div>
        </div>
      </div>
    </div>

Answer №4

display: flex;

Here's a CSS trick that worked wonders for me

Answer №5

Here is a possible solution to address your issue

It's difficult to determine if this is the exact cause of your problem, but it appears that <p> tags often have additional padding applied to them, resulting in an uneven placement on your website.

You can try eliminating the padding using CSS:

p {
  padding: 0;
}

Alternatively, you can add inline styles directly to your <p> element:

<p style='padding: 0'>

UPDATE:

Another possibility is that the useClass name lead may be introducing padding to the beginning of the <p> element. Consider removing the lead className from the <p> element, as shown below:

Before

<p class="lead  wow fadeIn"

After

<p class="wow fadeIn"

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

What is preventing the usage of $(this) in the jQuery .animate() function?

My progress bar is built with Bootstrap and here is the HTML code: $(".progress-bar").animate({ width: $(this).data('width') + '%' }, 2500); <!-- Latest compiled and minified CSS --> <link rel="styles ...

Transforming HTML into a JSON structure

Currently, I am in the process of converting some older code into a JSON object for a project. The task involves taking the result set from an SQL query and translating the categories it returns into JSON format. As someone with limited knowledge in JavaSc ...

How can I ensure the dialog title and button are centered, and how can I center a JQuery dialog box after the browser has

My current issue involves creating a dialog with centered text, but I'm struggling to achieve the same effect with the title and button. Additionally, the button I've created doesn't seem to be functional when placed in the dialog box. Despi ...

Clicking outside of a focused div does not trigger a jQuery function

Check out this HTML snippet: $html .= " <td><div class='edit_course' data-id='{$id}' data-type='_title' contenteditable='true'>{$obj->title}</div></td>"; Next, see the jQuery code below: ...

The value assigned to an HTML radio button gets cut off after a space

After reviewing the code snippet below, I noticed that when clicking Test 1 or Test 2, only "Test" is returned instead of the complete value. It seems like everything after the space in the value field gets cut off. Can anyone shed some light on why this i ...

Absolute positioning with centering margins

Hey there, I'm facing a little issue where I want to keep my footer at the bottom of the screen using position: absolute. But for some reason, the margin: auto that should center it on the screen isn't working as expected. Here's the HTML s ...

Ensure that adjacent elements operate independently from one another

The code snippet provided above showcases four components: StyledBreadcrumbs, FilterStatusCode, Filter, LinkedTable. The FilterStatusCode component enables users to input search data using TagInput. If the user inputs numerous tags, this component expands ...

Tips for optimizing background images for various screen sizes?

I'm experiencing an issue with my background image where the head is being cut off on larger screens. Is there a way to ensure that the entire picture is always displayed regardless of screen size? The initial property for background-size is set to co ...

Develop an engaging billboard carousel using jQuery

After coming across a tutorial on tympanus, I decided to make some modifications to create a rotating billboard effect. However, something seems to be going wrong and it's driving me crazy trying to figure out the problem! $(function() { $('#ad_ ...

What causes the columns in my table to move when a Bootstrap collapse is activated?

Utilizing Bootstrap's collapse feature, I want to create an expanding table row that reveals more details. When the row is clicked, the other columns seem to move slightly. It appears that this is somehow related to the length of the details, but I h ...

What is preventing internal CSS from functioning properly on mobile devices within the Gmail platform?

I have encountered an issue while sending an email from a PHP file to a Gmail account. The code I am using consists of basic HTML and CSS. Interestingly, the email looks perfect on desktop devices with all styles applied correctly. However, when viewed on ...

Turning HTML elements 90 degrees for vertical printing without the need for a landscape class

My current project involves creating a template for generating PDF files with CSS. I've set up different paper sizes and orientations using @page and media queries in my CSS code. You can check out a snippet of the CSS here. One challenge I'm fa ...

Creating two rows with responsive images using Bootstrap 4 is a simple and effective way to showcase your

Struggling to create a card game using Bootstrap 4 and Vue due to lack of front-end development skills. Looking to build two rows with responsive rounded images, each with a height of 25%. Here is the component code: <template> <div> ...

Background misalignment issue in Internet Explorer 6

My browser is IE6. [UPDATE: You can view the template live at this link: ] I have a template that utilizes 3 <a></a> tags to change the background position and create a button effect. This is how it appears in all browsers https://i.sstatic ...

Enhance Your Forms with Bootstrap 4 Input Extension

I've been struggling to create a form with Bootstrap 4, specifically setting the value in an input text client-side for a modal form. No matter what I try, it just doesn't seem to work... Here is the form: $('#contact-modal').on(& ...

Discover the method for invoking a Javascript function within a Leaflet popup using HTML

Upon clicking on a marker on the leaflet map, I aim to trigger a popup box that contains five elements: Title Description Image Button (Next Image) Button (Previous Image) To achieve this, I attempted to include a custom popup for each feature ...

Reducing the slide margins in impress.js?

When using Impress.js, I noticed that the default slides have a large left margin (or padding - it's hard to determine with Firefox's Inspector). I have a slide with a wide <pre> block that would fit if it were aligned to the left, but it d ...

What is the reason for the disappearance of unordered list bullets when using padding: 0?

Updating an older website that contains numerous unordered lists has presented a challenge. When the padding is set to 0, the display markers on the unordered list disappear. The root cause of this issue was traced back to the CSS setting *{padding: 0; ma ...

The dimensions of my grid object are constantly being altered by my interactive button

Recently, I started delving into vuejs and vuetify to work on a project management app for school. I encountered a simple problem where adding a button distorted the project bar. I tried nesting the button component within the project bar to rectify this i ...

Animated SVG Conversion (Icon to Scalable Vector Graphics)

I am having difficulty animating my SVG. I converted it from .ICO to .SVG using an online tool, but now I am unable to animate the strokedasharray and strokedashoffset properties. I've tried using fill but that hasn't worked. Below is my SVG code ...