HTML Introduction to HTML and CSS HTML: The Structural Foundation of Web Pages and Applications Paragraph Tags

jasgra
jasgra
1,734 Points

How can make a change to the default margin for the paragraph tag?

I believe the standard margin is 16px. Say I want to make it 5px, how can I do this?

I may be mistaken, but when I add an attribute to the tag > That refers to the css file. I add a new top and bottom margin for the <p(aragraph)>. This doesn't seem to do the trick.

I know that the largest margin overwrites the lower one. But apparently I doing something wrong.

Can you please answer my question. Thank you in advance!

jasgra:

Show your Workspaces code so everyone can see how it's written. You don't add an attribute to <p> tags inside the index.html file. The CSS styles it.

To give your paragraph a margin, you would write it in your styles.css file as: p { margin: 16px; }; or p { margin: 5px; }. Remember, cascading style sheets means that if the first margin is 16px, then you change the margin later to 5px, the latter margin overrides the previous margin.

2 Answers

Richard Crazythunder
Richard Crazythunder
2,322 Points

In your CSS section in the head of your HTML file (or the CSS file) you can define the parameters of a <p> element like this: p { margin-top: 100px; margin-bottom: 100px; margin-right: 150px; margin-left: 80px; }

Does that help? For future reference, w3schools.com is an excellent source of information and reference guide for all things related to fundamental HTML/CSS

jasgra
jasgra
1,734 Points

Yeah thank you. Because of all the class attributes (and css selectors) and overwriting one another, it was quite a search to get it right.

But it worked!

Also @ Kathryn Notson: Thank you!

jasgra:

You're welcome.

Also, when you have margins for each side of an element, start with the margin-top, margin-right, margin-bottom, then margin-left. It's always clockwise if you use 4 separate units. Here's a link to help you: http://www.w3schools.com/css/css_margin.asp.

Happy coding!