Jump to content

CSS Help


StormForum

Recommended Posts

Hello,I'm pretty new to CSS, and learning via the CSS section of W3Schools Web site. When I put the following code in my CSS file, how do I make it display on a normal web page.For example you put the following code in the CSS file:

p.right {text-align: right}

And so, you put the following code on a web page to make it display:

<p class="right">Text Here</p>

So if I put this code in the CSS file:

body {color: black}

What's the code for it to be displayed on a web page?


Also, ......
.center {text-align: center}

If I used that, do I "exactly" use the following code on a web page?

<p class="center">Text</p>

Sorry, I'm new to this, so any help appreciated! :)Thanks!

Link to comment
Share on other sites

Your body color css is automatically used when you have <body> in your page. So your text should me black. No need for classes. Without classes this means all occurrences of <body> will have a color of black since there is only 1 <body> by page this makes sense.By using .center {text-align: center}, this means any tags with class="center" will have it's content centered. It can be a <table class="center"> or a <ul class="center">. Your code <p class="center">Text</p> is correct and will work. Your first example p.right {text-align: right}, this means only <p> tags can be affected by your style. So if you have <table class="right"> it would not have any effect.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...