Welcome to the Streamlit community, and thanks for your detailed question! You’re running into a common limitation: when you use st.markdown to render HTML links, Streamlit can’t natively detect which link was clicked, because clicking a hyperlink doesn’t trigger a Python callback or update Streamlit’s session state. This is why st.session_state.textpara always ends up with the last value assigned in your loop, regardless of which link is clicked.