Huy guys,
Im new here (as the post counter suggests) and I have just started getting seriously into web design. I have hacked around a bit with some WYSIWIG editors and done a bit of basic HTML but I am currently working through the W3Schools Html and CSS tutorials... Anyway
One thing that I am not clear on is that with CSS It is possible to add conflicting styles to elements with classes. ie I divide my sites up into three sections using dev tags so that I have a menu at the top a body and a footer and give each section its own class. If I was to use the following code (please excuse any syntax errors as I am free typing from work)
all p text in the page should be black, but all text in the body class (referenced in the dev tags) should be blue but all p text with the body class should be red.
My question is how does the browser decide which style to apply? Is this considered "bad coding"?
Thank you.
Im new here (as the post counter suggests) and I have just started getting seriously into web design. I have hacked around a bit with some WYSIWIG editors and done a bit of basic HTML but I am currently working through the W3Schools Html and CSS tutorials... Anyway
One thing that I am not clear on is that with CSS It is possible to add conflicting styles to elements with classes. ie I divide my sites up into three sections using dev tags so that I have a menu at the top a body and a footer and give each section its own class. If I was to use the following code (please excuse any syntax errors as I am free typing from work)
Code:
p {color:black}
.body {text-color:blue}
p.body {text-color:red}
all p text in the page should be black, but all text in the body class (referenced in the dev tags) should be blue but all p text with the body class should be red.
My question is how does the browser decide which style to apply? Is this considered "bad coding"?
Thank you.
Last edited: