Jump to content

class selector


eddie0504

Recommended Posts

If there is someone who can help me answer this question I would greatly appreciate it.I am aware that with class selector you can define different styles for the same type of HTML element.example:p.right {text-align: right}p.center {text-align: center}My question is: Are there standard style attributes that need to be used after the period "." or can I just make up any word.example:span.big {font-family:"Monotype Corsiva";font-size:36pt;color:#FFFFFF}This example seems to have worked for me when I tested it in the browser but I am concerned as to if I am writing the code correctly.Also XHTML should be written in lowercase. Does this rule also apply to hex values such as the example above: #FFFFFFThanksEddie

Link to comment
Share on other sites

Well, I'm not sure I follow what you are asking for.What I typiclly do is grab elements from the id.Say I have an id of computer.

#computer {font-weight:bold;padding:5px;}

Then I decide that I want all my text inside of that div to be red and right justified. But, only that text. The rest I want left alone.I could do this:

#computer p {color#ffcc00;text-align:right;}

See how that works?Keep in mind, that because the container div (computer) sets my fonts to bold, any text will still be bold. Unless you tell it otherwise.Instead of creating a bunch of classes, just use container ID. That will help cut your code down as well.As far as lower case, yeah...it's a good idea to keep everything lower-case in your css file and markup.Hope this helps!

Link to comment
Share on other sites

My question is: Are there standard style attributes that need to be used after the period "." or can I just make up any word.
There is not such restriction for CSS class names, except, Do NOT start a class name with a number, It will not work in Mozilla/Firefox..... Also its better to use lowercase for CSS too.
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...