Brian Ruff
Brian Ruff

Reputation: 105

HTML/CSS paragraph tags

I was wanting to know if there is anything wrong with writing the paragraph tags within the code body tags like this:

paragraph tag question

I'm very new to programming and HTML/CSS as well, but I have not seen any coding examples doing this. I do see people using h1, h2, h3, etc... but these text sizes are different by default where the p and p1 tags give the same exact size. Also, would writing the code like this cause any problems with commonly used browsers?

The reason I want to do this is because I can change each paragraph using the CSS style section of the code rather than setting each paragraph to the same paragraph tag and then the corresponding attributes affect all the paragraph text.

thanks and sorry if this has been asked before, but I couldn't find it on the web

Brian

Upvotes: 2

Views: 1561

Answers (1)

I haz kode
I haz kode

Reputation: 1635

Use <p class="first"></p> <p class="second"></p> <p class="third"></p> and so on.

These are called classes.

You can define classes in your CSS sheet and style them independently without affecting other elements which don't have the class.

Identifiers such as "first", "second" and "third" are arbitrary, you can choose your own class names.

.first {
  color: red
}

.second {
  color: blue
}

.third {
  color: green
}
<p class="first">I am a paragraph</p>
<p class="second">I am a paragraph</p>
<p class="third">I am a paragraph</p>

Upvotes: 1

Related Questions