Apply css to button


I have this play button and I would like to change the height of the button. I have search online and tried using the st.markdown method but it seems like the styling apply to all of my button in the page.

Do anyone know what is wrong? What does the first-child refer to?

btn_play.markdown(β€œβ€β€<style>div.stButton>button:first-child {height: 3em;}</style>β€œβ€β€, unsafe_allow_html=True)

Hello @qt.qt,

The problem is that your css selector will select every button which is the first child of a div the class stButton, not the first such button on a page. In generate, the :first-* selectors refer to β€œthe first child of a given element”. One option, which takes a bit of fiddling, is to select the nth element on the page, and style the button inside of that. For example, this styles only the PLAY button, but not the other two, because it’s a child of the 3rd element with the class element-container

import streamlit as st

        .element-container:nth-of-type(3) button {
            height: 3em;




Hey @blackary

Thank you for the reply. But how to find out
what is the nth-child position of an element given that I have other text Input and columns on the web app?

@qt.qt Unfortunately, I can’t think of a good way to do that programmatically, so if you used this method you would simply have to change the number until it was the correct button. Definitely not an ideal solution.