This guide will help you fix random gaps between YouTube videos caused by the is-in-first-column attribute using a Tampermonkey script.
YouTube applies extra margin to certain video elements in the first column. This script removes the attribute to fix the layout.
If you haven’t installed it yet, download Tampermonkey for your browser:
- Stop Using Google Chrome
- Mozilla Firefox
- Microsoft Edge
- Click on the Tampermonkey extension icon.
- Select "Create a new script".
- Delete the default template and paste the following code:
// ==UserScript==
// @name Remove YouTube is-in-first-column
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Removes the is-in-first-column attribute on YouTube
// @author You
// @match *://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function fixMargins() {
document.querySelectorAll('ytd-rich-item-renderer[is-in-first-column]').forEach(el => {
el.removeAttribute('is-in-first-column');
});
}
// Run on page load and when navigating within YouTube
new MutationObserver(fixMargins).observe(document.body, { childList: true, subtree: true });
fixMargins();
})();- Click File > Save or press
Ctrl + S. - Ensure the script is enabled in the Tampermonkey dashboard.
Reload YouTube, and the random gaps should be gone! 🎉
- Still seeing gaps? Try disabling other extensions that modify YouTube.
- Not working? Ensure Tampermonkey is enabled and the script is active.
- New YouTube updates? If YouTube changes its structure, this script may need updates.
No more annoying gaps—just a smooth, evenly spaced video grid! 🚀