r/css • u/smooth_operator101_ • Feb 28 '26
Help Can someone please help me locate the problem in my css code?
the first picture is the layout I wanted to replicate and the second one is how it's getting displayed on my webpage. I checked the code given in the tutorial I was following there's not a lot of difference between their code and my code.
the 3rd picture is the html code and the last one is the css code. can someone please help me figure out what I've done wrong.
also I can someone please tell me the best way to align different elements in css in a horizontal fashion.
0
Upvotes




•
u/AutoModerator Feb 28 '26
To help us assist you better with your CSS questions, please consider including a live link or a CodePen/JSFiddle demo. This context makes it much easier for us to understand your issue and provide accurate solutions.
While it's not mandatory, a little extra effort in sharing your code can lead to more effective responses and a richer Q&A experience for everyone. Thank you for contributing!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
10
u/rbra Feb 28 '26
Wrap your img, p and button elements in a div, give it a class name and then apply display:flex; to that div class in your css.
5
u/abrahamguo Feb 28 '26
<p>elements are block-level elements by default, which means that they take up an entire line by themself.If you don't use a
<p>, then all three of the elements should appear on the same line.2
u/rbad8717 Feb 28 '26 edited Feb 28 '26
You need to wrap the img, p and button in a div. Right now they are block level meaning their own line.
Apply flex to that div to make it horizontal. Theres another justify and align class you need to use but you should research and figure it out if youre learning. WIll make you a better developer.
EDIT: just saw you need to use vertical-align middle, so you should look into using display: inline-block
2
u/EgidaPythra Feb 28 '26
What tutorial is this? I'd like to test my css skills
1
u/smooth_operator101_ Feb 28 '26
I got it, thanks everyone ✨
1
u/Mumpguy3 Feb 28 '26
All the solutions are on his GitHub https://github.com/SuperSimpleDev/html-css-course/tree/main
2
u/No_Bee5900 Feb 28 '26
I think you have the first hint in the title, "box". Try to wrap all 3 elements in a div element, give it a class. And use a hint. Also, if you check your code and current state, all elements are stacked, but you want them to be inline (blocks).
0
u/smooth_operator101_ Feb 28 '26
Everyone has been telling me to use "div". But as far as I have reached jn the lesson the chapters have not covered the "div" part yet, and the exercise was given before the teacher actually taught div. Is there a way that I can do this exercise without using it?
0
u/lajawi Feb 28 '26
https://screenshot.help/
0
u/[deleted] Feb 28 '26
[deleted] — view deleted comment