import streamlit as st
button_col, other_col= st.columns([1,3])
st.markdown("""
<style>
[data-testid=column]:nth-of-type(1) [data-testid=stVerticalBlock]{
gap: 0rem;
}
</style>
""",unsafe_allow_html=True)
with button_col:
"*Modified gap:*"
st.checkbox("text")
st.checkbox("text1")
st.checkbox("text2")
with other_col:
"*Unmodified gap:*"
st.checkbox("text4")
st.checkbox("text5")
st.checkbox("text6")
st.markdown("## A header")
st.markdown("🪄 This is a repeated sentence"*100)
Sure, so this changes the gap between elements in the first column to 0rem. The logic behind it is that it looks for all the column elements in the page ([data-testid=column]), then picks the first one (:nth-of-type() selector), and then it selects the [data-testid=stVerticalBlock] element, which is the one that has the gap property. Notice that gap: 0rem does not apply to the checkboxes but to everything placed in that first column, so it should apply for selectboxes or whatever you put in there.
Here is a better explanation on how to find those tags and target particular css properties on an page: