Why isn't my margin-top working?

Hello everyone, I have tried a lot of things now, asked ChatGPT, told friends, rewrote everything myself and don't know what's wrong, can you help me?

Here's the problem: I'm writing HTML and CSS code and I don't understand why the last line

margin-top:200px; not working why is the span attribute still stuck so tightly at the top despite the margin 200

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
10 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
VeryBestAnswers
1 year ago

a has by default display: inline, whereby vertical margins have no effect. To set a margin, you must either use a

or the CSS property display display set, for example inline block.

More information on MDN

VeryBestAnswers
1 year ago
Reply to  s180025

I just looked back. For inline elements, horizontal margin can be set, but no horizontal margin. I’ve edited the answer to correct it.

VeryBestAnswers
1 year ago

6 hours are not enough to go to any strange corner case of CSS. I have been using CSS regularly for about 7 years, and meanwhile I have quite a good intuition for it, but I would not say that I can understand and explain everything by now.

TheQ86
1 year ago

A style block actually belongs to the section. I don’t know if that’s the mistake. Browsers tend to forgive any misformatting.

Rolajamo
1 year ago

I think this needs a float or position attribute.