My website's h1 header title seems to be unresponsive and not adjusting correctly

Everything was smooth sailing during the creation of a responsive website until I decided to customize my header with my preferred font-family, font-size, and letter-spacing. Once I scaled it down to less than 600px for mobile, things started looking odd.

Why is my header protruding out of the <body></body> area in an unusual manner even though my

<div class = "header"></div>
is still within the <body></body> tags? Please see the attached screenshot. Any assistance would be greatly appreciated.

Below is the HTML and CSS code for reference:

https://i.sstatic.net/lMq2j.jpg

*{
box-sizing: border-box;
}

...
... (Remaining CSS Code)
...
</footer>
</div>

</body>
</html>

Answer №1

The font size is currently too big for the available space. In order to make it fit, you can either decrease the font size or instruct the browser to break the text at word boundaries using word-break: break-word.

Answer №2

Check out the code snippet below. Adjust the CSS in media query for .header and .header h1 to modify padding and font size. Feel free to reach out if you need any further modifications.

*{
box-sizing: border-box;
}

body {
width: 100%;
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}

/* The header section */

.header {
background-color: #ccccff;
text-align: center;
padding: 80px;
}

.header h1 {
font-size: 68px;
font-family: "Lucida Console", Monaco, monospace;
letter-spacing: 10px;
}

/* The main content section */

.content {
padding: 10px;
background: #e6e6e6;
}

.content h2 {
text-align: center;
}

.content p {
margin: 30px;
}

/* Three equal columns */

/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
padding: 10px;
}

/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}

/* This is the footer section */
footer {
width: 100%;
height: 100%;
padding: 50px;
text-align: center;
background: lightgreen;
}

/* Responsive design starts here */

@media only screen and (max-width: 768px) {
.column {
width: 100%;
}
  .header{
  padding: 10px;
  }
  .header h1{
  font-size:40px;
  }
}
<!DOCTYPE html>
<html>
<head>
<title>Title Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

<!-- This is a header -->
<div class="header">

<h1>Website Title</h1>
<p>Dolor sed veniam minim eiusmod sint labore elit lilamco dolor in in dolor clipa occaecat do.</p>

</div>

<!-- This is the main content -->
<div class="content">

<!-- About section -->

<h2>About</h2>
<p>
Lorem ipsum clipa nlila tempor amet dolor clipa magna commodo minim. Sed ut lilamco veniam est esse tempor in anim excepteur lilamco excepteur deserunt ad. Lorem ipsum tempor eiusmod nisi consectetur magna cupidatat in ad velit clipa aliqua id sunt clipa nlila aliqua laboris.
</p>

<!-- 3 column responsive layout -->

<div class="row">

  <div class="column" style="background-color:#aaa;">
    <h2>Column 1</h2>
    <p>
    Magna velit dolor esse magna ut sed cillum magna lilamco nisi ut. Qui labore in sed ea excepteur clipa laboris pariatur irure fugiat fugiat dolor qui. Velit aliquip fugiat eu ea dolor velit proident veniam consectetur ut dolor clipa sunt incididunt veniam duis nisi tempor.
    </p>
    <ul>
    <li>Skill 1</li>
    <li>Skill 2</li>
    <li>Skill 3</li>
    <li>Skill 4</li>
    <li>Skill 5</li>
    </ul>
    
  </div>


  <div class="column" style="background-color:#bbb;">
    <h2>Column 2</h2>
    <p>
    Magna velit dolor esse magna ut sed cillum magna lilamco nisi ut. Qui labore in sed ea excepteur clipa laboris pariatur irure fugiat fugiat dolor qui. Velit aliquip fugiat eu ea dolor velit proident veniam consectetur ut dolor clipa sunt incididunt veniam duis nisi tempor.
    </p>
    <ul>
    <li>Skill 1</li>
    <li>Skill 2</li>
    <li>Skill 3</li>
    <li>Skill 4</li>
    <li>Skill 5</li>
    </ul>
    
  </div>


  <div class="column" style="background-color:#ccc;">
    <h2>Column 3</h2>
    <p>
    Magna velit dolor esse magna ut sed cillum magna lilamco nisi ut. Qui labore in sed ea excepteur clipa laboris pariatur irure fugiat fugiat dolor qui. Velit aliquip fugiat eu ea dolor velit proident veniam consectetur ut dolor clipa sunt incididunt veniam duis nisi tempor.
    </p>
    <ul>
    <li>Skill 1</li>
    <li>Skill 2</li>
    <li>Skill 3</li>
    <li>Skill 4</li>
    <li>Skill 5</li>
    </ul>
    
  </div>

</div>



</div>

<!-- This is the footer -->
<div class="footer">
<footer>
Person Name &copy; 2019
</footer>
</div>

</body>
</html>

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

I seem to be having an issue with the decimal point on my calculator - I only want to see one dot

Only need one dot for the calculator to function properly. The current situation with multiple dots is causing confusion. I intend to address other aspects of the code later, but I'm currently struggling with this issue. function dec(d) { let ...

How to Align the Button Vertically with the TextField in React Material-UI

Utilizing the Material-UI library for React, I have been working on creating a simple form with the following design: https://i.stack.imgur.com/LY3ZN.png My challenge lies in aligning the button with the TextField element. Adjusting the margin-top proper ...

Displaying content using Jquery's slideDown feature, overlapping existing content

I am working on displaying one piece of content over another using Jquery slidedown as an overlay. Despite adding z-index properties, I am struggling to make it work. My goal is to have the div with class "selection_nip" appear as an overlay on top of ano ...

Guide on positioning content around an image

I am currently in the process of developing an about page for my personal website. I am seeking advice on how to achieve a text wrapping effect around an image, similar to what is showcased on this website: Below is the code I have implemented thus far: ...

Incorporating font options for a PDF generator package within the Symfony framework

I'm currently working on a Symfony project where I need to export PDF code that includes images and text stored in the database. Since I can't install anything on the web servers, I've opted for using the Spread PDF Generator Bundle instead ...

Tips for transferring information between two distinct pages utilizing the jQuery POST technique

I'm dealing with two PHP files called card_process.php and payment.php. My goal is to transfer data from the cart_process page to the payment page. Here's a snippet of the code: In cart_process.php: $paynow = "<button type='submit' ...

Visibility of text compromised when placing transparent button inside input field

After adding a clear button inside the input box in Angular, I am facing an issue where the text in the input box is being overlapped and not fully visible. Below you will find detailed information on this problem. HTML Code <ng-template pTemplate=&quo ...

How can you easily make a div scroll vertically in the Android Browser?

Important Note: While similar questions have been asked before, it's important to consider that the mobile web is constantly evolving. The discussions from a few years ago may no longer be relevant due to updates and changes in technology. I am curre ...

Troubleshooting issue with applying Select2 class dynamically with JavaScript

When developing my web application, I faced a challenge of dynamically adding new rows to a table using JavaScript. The row contains a <select> element which loads data from the ViewBag for its <options>. Additionally, I wanted to apply the Sel ...

Display the second dropdown after the user has made a selection in the first dropdown

Recently, I've been delving into the world of html/javascript and navigating through the process of implementing the code found in this specific link. While I can see the solution outlined in the link provided below, I'm struggling with how to i ...

Stop text from wrapping around the amazing fonts image

I am facing an issue with displaying an image using awesomefont character with text next to it. The problem is that I want the text to be right-justified beside the image instead of appearing below it. Despite trying different alignment codes and container ...

Trouble encountered when attempting to download PDF using jQuery

I have encountered an issue while trying to download a PDF using Ajax response HTML. Here is the code I am using: var newPDFAction = function () { $.ajax({ type: "post", url: '{{ route("admin.getCustomerSalesRepTota ...

Overflow issue with floating labels in Bootstrap 5 within a grid container

Incorporated within this code snippet are floating selects placed inside a bootstrap grid: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4b6bbbba0a7a0a6b5a494e1fae7fae7">[emai ...

Display or conceal columns based on their index

<div ng-controller="checkBoxController"> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="moda ...

What is the best way to retrieve the value of a Bootstrap 4 form dropdown in PHP as soon as it is selected?

How can I retrieve the selected value from a form dropdown in Bootstrap 4 using PHP as soon as it is chosen? <div class="form-group"> <label for="dropFields">Field:</label> <select class="field-select form- ...

Creating an arrow line with CSS styling can be achieved easily

In order to create a horizontal line with a breakdown in the middle that displays an arrow, I want to use only HTML and CSS without relying on bitmap images. If needed, Font Awesome can be used to achieve the desired result. It's important for me to h ...

Elevate the value of a particular element's variable through the execution of a function

By using a for loop, I was able to generate a variable number of divs that change their background color individually when hovered over with the mouse. Now, I want to implement a function that will decrease the brightness of each div by 10% every time it i ...

Having issues with column offsetting in Bootstrap v4.0.0-beta

While using Bootstrap 4 Beta (Bootstrap v4.0.0-beta), I encountered an issue with offsetting columns. Previously, I used offset-md-* and it worked fine. However, this feature has been removed in BS4 Beta as per the documentation. The new method suggested i ...

Shift the sideways movement of the triangle symbol

I currently have a main menu in the header with links, accompanied by a moving triangle that changes position as the user hovers from one page to another. While I want to maintain the dynamic movement, I am seeking a smoother transition effect similar to w ...

Tips for transferring a prop from a parent component to a child in Vue.js

I have a main component named Stepper that includes a child component called ShortSummary. I am attempting to pass a property from Stepper to ShortSummary by clicking on a radiobutton, but it is not working! Here's my setup. This is the code for Stepp ...