Why is there white space/padding occurring within this div element?

I need the red border to be snugly wrapped around the blue text (no whitespace). What is causing the extra space and how can I eliminate it?

#propertyDetails .display_address {
font-size: 1.75rem;
font-weight: bold;
color: #3498db;
margin:0px;
padding:0px;
border: 1px solid red;
}
<div id="propertyDetails">
<div class="display_address">Test Address</div>
</div>

Answer №1

If the current setting is not suitable for your screen, try changing the line-height to 16 pixels or adjust it according to your preferences.

Answer №2

The reason for this issue lies in the line-height. To fix it, set the line-height to 1, which is equivalent to 100% of the font-size. This way, even if the font-size changes, you won't have to adjust the line-height separately.

#propertyDetails .display_address {
font-size: 1.75rem;
font-weight: bold;
line-height: 1;
color: #3498db;
margin:0px;
padding:0px;
border: 1px solid red;
}
<div id="propertyDetails">
<div class="display_address">Test Address</div>
</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

Navigation bar disappears when overlapped by iframe video from BBC News website

An interactive demo has been created at the following link to showcase the issue: . Hovering over 'about' on the top right menu should activate a dropdown menu with dark opacity directly beneath the menu, overlaying the iframe video. While every ...

Change the background color of a single row in the Foundation table using Angular

When displaying a list of users, I need to emphasize a specific row that corresponds to a user's current rank. However, I am facing an issue with ng-class as it does not appear to override the Foundation background-color for that particular row even w ...

Sleek design featuring a header, footer, Left Menu, Content, and RightMenu implemented on Bootstrap 4-5

Can you help me create a minimal layout using Bootstrap 4-5 with a header, footer, LeftMenu, Content, and RightMenu? The combined width of LeftMenu, Content, and RightMenu should be similar to the main block on the current site (htmlforum.io). This means ...

Using JQuery to search for and remove the id number that has been clicked from a specific value

I am in need of assistance with deleting the clicked id number from an input value using jQuery. I am unsure of how to proceed with this task and would appreciate some guidance. To simplify my request, let me explain what I am trying to accomplish. Take ...

Managing concurrent users updating the same form on a web application

Imagine a scenario where user A opens a form with pre-filled data. While user A makes changes to the form data, user B also opens the same form with the data intended for user A. Just as user B begins modifying the data, user A clicks on the submit butto ...

Why are my subpages not appearing when using nodejs?

Currently, I'm in the process of creating a basic node app for my website. So far, I have set up my app.js, controllers, and routers. However, I am encountering an issue where two out of three subpages return a 404 error, while the index page works ...

Tips for retrieving HTML file content as a string using JavaScript

I'm looking to retrieve the contents of an HTML file using JavaScript and store it as a string. I tried writing some code for this purpose, but unfortunately, I encountered an error: Error: Cannot find module 'xmlhttprequest' Could someone ...

Using the createElement method in React to restart a GIF animation

In my React project, I'm attempting to develop a function that generates a new element displaying a gif for one loop before removing it. My current approach looks like this: function playGif() { var gif = document.createElement('img') ...

Utilizing RSelenium to scrape information from multiple webpages within a newspaper archive website

I successfully extracted data from a single page of a newspaper archive by following instructions shared here. Now, I am aiming to automate the process by creating a code that can access and scrape a series of pages effortlessly. Generating a list of URLs ...

Is the text alignment off?

I've been immersed in creating a website, but I encountered an issue for which I can't seem to find the solution. Check out my text alignment here (test) - it's not aligned all the way to the left of the content Here is the HTML code: < ...

Issues following compilation with npm run prod

I am currently working on a small website using Laravel and Tailwind CSS on shared hosting. While I am able to use a command line tool on the host, I have encountered an issue. In my local environment, Tailwind works perfectly fine. However, after running ...

Utilizing Angular's ng-repeat with varying directives for each iteration

I am trying to utilize ng-repeat within Angular to iterate through multiple <li> elements with a directive embedded. My goal is to have the first two items in the ng-repeat display differently in terms of styling and content compared to the remaining ...

What is the best way to grasp the concepts behind MaterialUI styled components?

Can someone please help me understand how to apply styles to a component using MaterialUI? I've been reading the documentation but it's all very confusing to me. What exactly are classes and how do I connect the const style to the BeerList compon ...

Why is my Bootstrap Carousel Switching Images but Refusing to Slide?

I've encountered a problem with my bootstrap carousel. The slide effect doesn't seem to be working, even though I have added the "slide" CSS tag. Instead of sliding, the images just quickly change without any transition. Here are some key points ...

Grid Bloc 5 Foundation

Check out this code snippet: HTML <div class="medium-12 columns videos"> <ul class="medium-block-grid-2 text"> <li><iframe src="//www.youtube.com/embed/vid1" frameborder="0" allowfullscreen></iframe></li> < ...

The image displayed on the HTML scrset attribute is not the correct one

I'm experiencing an issue with correctly loading the responsive image using scrset. The sizes attribute I am using is: sizes="(max-width: 767px) 95vw, 768px" and for the srcset attribute: srcset="https://cdn.runningshoesguru.com/wp-content/uploads ...

Ways to enable users to input grammatical equations while verifying certain rules in a text box

I am looking for validation of equations in HTML, not evaluation. I want to allow users to input equations like the following in a textbox, with validation: 400 - IF(age > 32, 6, 4) + 10 The 'age' is a fixed string, and there will be other ...

Certain line borders are more robust compared to the rest

I have been working on a calendar application where I have designed boxes to display dates. However, I have encountered an issue where some of the line borders appear darker or thicker than others. Below is a snippet of my CSS and HTML code: <style> ...

Tips for creating animated card designs with HTML, CSS, and JavaScript

As I delve into the realm of CSS animation, my primary focus is on replicating the captivating card shuffling animation showcased at Here's a glimpse of the progress I've made so far: https://youtu.be/GDIJ2K22cnY While I've successfully im ...

The CSS background-image fade transition is optimized for Chrome browsers

HTML: <a class="navbar-brand page-scroll" href="#intro"></a> CSS: .navbar-custom .nav li a.navbar-brand { width: 70px; height: 62px; background: url(myimg.png) no-repeat; background-size: 70px 62px; display: block; po ...