Tips for eliminating unnecessary white space using CSS

https://jsfiddle.net/38h8acaq/

Is there a way to eliminate the white space on the left of the first tab and between the tabs and the content? Despite adding several margin:0px; lines to the CSS, none seem to be effective in removing the unwanted whitespace.

<div class="tabs">
    <ul class="tab-links">
        <li class="active"><a href="#tab1">Tab #1</a>

        </li>
        <li><a href="#tab2">Tab #2</a>

        </li>
        <li><a href="#tab3">Tab #3</a>

        </li>
        <li><a href="#tab4">Tab #4</a>

        </li>
    </ul>
    <div class="tab-content">
        <div id="tab1" class="tab active">Content tab1</div>
        <div id="tab2" class="tab">Content tab2</div>
        <div id="tab3" class="tab">Content tab3.</div>
        <div id="tab4" class="tab">Content tab4</div>
    </div>
</div>

Answer №1

Perhaps you could experiment with padding-left: 0px? It appears to be effective in this case.

Answer №2

modify

.tab-links ul {
   margin: 0px;
}

to

.tabs ul{
   margin:0px;
}

illustrate with HTML

 <ul class="tab-links">
    <li class="active"><a href="#tab1">Tab #1</a>

    </li>      
</ul>

Explanation. I noticed that the ul you needed was not directly under the selector so I adjusted the CSS accordingly by selecting the parent element of the necessary ul.

updated fiddle

Answer №3

To eliminate the space from the first left tab, you can apply the following CSS:

.tab-links {
    margin-left:0;
    padding-left:0;
}

.tab-links li:first-child {
    margin-left:0;
}

You can view the updated example here: https://example.com/updated

Answer №4

Regarding your initial inquiry,

The tab links currently have a style of padding-left:40px,

To override this, use the following code .tab-links{padding:0}

Answer №5

.tabs {
width: 100%;
display: inline-block;
}
/*----- Tab Links -----*/

/* Clearfix */
 .tab-links:after {
display: block;
clear: both;
content:'';
}
ul.tab-links {
padding: 0;
margin: 0px;
}
.tab-links li {
margin: 0px 5px;
float: left;
list-style: none;
margin-bottom:0px;
}
.tab-links li:first-child{
 margin-left: 0;
}
.tab-links a {
padding: 9px 15px;
display: inline-block;
border-radius: 2px 2px 0px 0px;
background: #7FB5DA;
font-size: 16px;
font-weight: 600;
color: #4c4c4c;
transition: all linear 0.15s;
margin:0px;
}
.tab-links a:hover {
background: #a7cce5;
text-decoration: none;
}
li.active a, li.active a:hover {
background: #da7fca;
color: #4c4c4c;
}
/*----- Content of Tabs -----*/
 .tab-content {
margin: 0px;
padding: 10px;
border-radius: 2px;
background: #ff0005;
}
.tab {
display: none;
margin: 0px;
}
.tab.active {
display: block;
}
<div class="tabs">
<ul class="tab-links">
    <li class="active"><a href="#tab1">Tab #1</a>

    </li>
    <li><a href="#tab2">Tab #2</a>

    </li>
    <li><a href="#tab3">Tab #3</a>

    </li>
    <li><a href="#tab4">Tab #4</a>

    </li>
</ul>
<div class="tab-content">
    <div id="tab1" class="tab active">Enjoy the beauty of nature and discover its wonders. Explore breathtaking landscapes and captivating wildlife species. Immerse yourself in the tranquility of untouched environments.</div>
    <div id="tab2" class="tab">Experience thrilling adventures and adrenaline-pumping activities. Challenge yourself with daring feats and embark on unforgettable journeys into the unknown.</div>
    <div id="tab3" class="tab">Delve into rich cultural heritage and traditional customs. Witness the vibrant tapestry of diverse communities and celebrate the unique traditions that define them.</div>
    <div id="tab4" class="tab">Indulge your senses with delectable cuisines and culinary delights. Savor the flavors of exotic dishes and taste the essence of different culinary heritages from around the world.</div>
</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

Is there a way for me to view the specifics by hovering over a particular box?

Whenever I hover over a specific box, detailed information appears, and when I move the mouse away, the details disappear. HTML <nav> <div> <div class="nav-container"> <a href="./about.html" ...

A one-page digital space that functions as a dynamic slide show

Check out this cool website I want to emulate. The site is a single-page design where you can navigate vertically using various methods like keyboard, mouse, scroll, or swipe gestures. There are carousels that allow left and right navigation. Each section ...

The functionality to open the menu by clicking is experiencing issues

I'm attempting to replicate the Apple website layout. HTML structure: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" conte ...

Revise website design to adjust dynamically according to screen dimensions

Currently, I am working on a school project with a website created by former students. Unfortunately, I have limited knowledge of HTML and CSS which has made it challenging for me to ensure the site is mobile-friendly. There are issues such as text overflo ...

Utilizing Google Maps to generate outcomes for an online platform

My approach with Google Maps is a bit unconventional. Instead of rendering images, I aim to execute JavaScript code that processes data and returns a text response. However, I soon realized that running JavaScript as a remote web service might not be pos ...

Using a <button> tag instead of a <div> inside of a <button> is not allowed, as clickable divs are typically frowned upon. What

I'm currently developing a React App that functions as a calendar, allowing users to click on specific days displayed as large squares to view information for that day. For accessibility purposes, I initially considered using <button> elements b ...

Issues with Bootstrap Carousel Slide Show functionality in FireFox

I have implemented a Bootstrap-5 Carousel Slide Show for the website banner. It is functioning correctly in Google Chrome, but there seems to be an issue when viewed in Firefox. The Firefox browser version I am using is 90.0.2 (64-bit). Upon inspecting the ...

Including an image side by side with clickable text within a list

Check out my progress here: http://jsfiddle.net/dDK6z/ I've experimented with using display:inline(-block), as well as adjusting margins, padding, and more, but I can't seem to get the image to move down or the text to move up. Does anyone have ...

How can I trigger an Onclick event from an <a tag without text in a Javascript form using Selenium?

Here is my original source code: <a onclick="pd(event);" tabindex="0" issprite="true" data-ctl="Icon" style="overflow: hidden; background: transparent url("webwb/pygridicons_12892877635.png!!.png") no-repeat scroll 0px top; width: 16px; height: 16px ...

Disable the meta tags in Zurb Foundation 5

I have searched extensively online but haven't been able to find a solution for this issue. How can I disable these zurb foundation 5 meta tags in the <head>: <meta class="foundation-mq-small"> <meta class="foundation-mq-small-only"> ...

Switch up div content - advertisements at the top or bottom

An issue has arisen where the ads on a website are currently being displayed at the bottom of the source code, but they should actually be visible at the top. Here is the ad placeholder code: <div id="300_250_placeholder"></div> And here is ...

Is there a way to send emails with subject lines containing special characters?

I am facing an issue where, when I send an email with the subject containing "Ç", it displays as "?". I have tried various implementations to fix this such as using -charset="ascii", -charset=UTF-8, and modifying the subject line with different encodings. ...

Where could one possibly find the destination of the mysterious <circle>?

I want to implement a simple pulsating animation on a circle svg element. I attempted using a transform: scale(..,..) animation, but it seems to be shifting the entire circle within its container instead of just scaling the element itself. This is the cur ...

Tips for troubleshooting ImageArray loading issues in AngularJS

Having some trouble learning Angular and getting stuck with this Image array. Can someone please help me understand what's wrong with my code and how to fix it? FilterAndImages.html <!DOCTYPE html> <html ng-app="store"> <head> < ...

What is the best way to extract styled HTML tags from I18N properties files using the Makara module in conjunction with Express and Kraken.js?

I'm currently utilizing Makara, an I18N module designed for Kraken.js and Express.js. Imagine a scenario where I need to format a specific word within a sentence, but its placement varies based on different languages. I want to ensure that this can b ...

Arranging Bootstrap inputs horizontally with lengthy labels

When placing two input fields in a row, such as a drop down menu, with labels of varying lengths, the alignment of the inputs can become skewed. This issue persists even when attempting to add breaks in the code due to unpredictable wrapping behavior at di ...

Troubleshooting problems with jQuery mmenu on Windows Phone (IE Mobile)

I am currently working on optimizing the mobile version of a website, utilizing jQuery MMenu for the menu. The functionality is seamless on various phones and tablets I have tested, except for Windows Phones... Even with the plugin configured with the "po ...

The CSS formatting is not being properly applied within the innerHTML

I have a scenario where I am trying to display a Bootstrap card using innerHTML in my TS file, but the styles are not being applied to this content. I suspect that the issue might be because the styles are loaded before the component displays the card, cau ...

Ways to animate elements while scrolling in React.js?

I am new to using React.JS and currently working on setting up an E-commerce Store. My goal is to have 5 images stack on top of each other and move together as the user scrolls. I used to achieve this effect in Vanilla JavaScript by adding a window.addEven ...

What are the steps to create a unique popup div effect with jQuery?

Upon clicking the icon on this page, a mysterious div appears with information. I'm completely baffled by how they achieved this cool effect using css/jQuery tools. Can anyone shed some light on the mechanism behind this? ...