Jump to content
xisto Community
csp4.0

Need Help On Css

Recommended Posts

Ok, so i'm making another website. But I have run into a problem!
Transforming XHTML code from Transitional to Strict isn't very easy, and what's worse? The original code had over 100 validation errors.

I have managed to reduced that number to 6 errors.

Ok, so the main problem is... After I fiddled around with the CSS code and managed to take away the

leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"

code from the
<body>
tag and put them in CSS as

body {	margin-top: 0px;	margin-right: 0px;	margin-bottom: 0px;	margin-left: 0px;}

but the code seems to have problems keeping borders at bay...

so now I have white borders surrounding every little table and picture! so what would fix this? I would really want to stay within the XHTML Strict rules. So help?... Anyone?

Share this post


Link to post
Share on other sites

http://www.w3schools.com/css/css_border.asp

 

Basic css format:

body { border: 0; }
to eliminate all Borders. Place this on the body and they should all go away.

 

Then add them back into the page as you need them on various Elements.

 

ie:

p { border: 2 px solid red; }
for a 2px wide red border on Paragraph elements.

 

or:

p.pretty { border: 2 px solid red; }
for a 2px wide red border on Paragraph elements of the class "pretty". Be sure to add the class="pretty" to those Elements. Multiple Elements can be using the same class name of a page.

 

or:

p#pretty { border: 2 px solid red; }
for a 2px wide red border on Paragraph elements of the id "pretty". Be sure to add the id="pretty" to those Elements, and remember, there can only be one occurrence of an id on each page.

 

Of course, IE will likely not obey this Rule the same way as Standards Compliant Browsers, but it is a start...

Share this post


Link to post
Share on other sites

oh thank you so much jlhaslip!

Now I need some other help with CSS... because the height and width attributes aren't valid in XHTML 1.0 Strict and the CSS alternatives are height:x; and width:x; but for some reason when I try to use the CSS ones it doesn't work but when I use the non-valid XHTML tags it does work...

<td colspan="4" style="background: url(images/sg_12_02.jpg);" width="241" height="9">


is one piece of code that will not work if I do this

<td colspan="4" style="background: url(images/sg_12_02.jpg); width:241; height:9;">

So what should I do? is there any mistake I made? or what?
Edited by csp4.0 (see edit history)

Share this post


Link to post
Share on other sites

you need to use the units when specifying the height and width attributes for the images or any other element.

use the following code and it should work and is 100% valid HTML Strict :P

<td colspan="4" style="background: url(images/sg_12_02.jpg); width:241px; height:9px;">

I'd suggest that you should use a separate file as style sheet containing all the styles and never use inline styles. I'd also suggest that you'd use div's and css for positioning and layout of your webpage as per the Web Standards. This will greatly help you achieve lighter and neat page.

Share this post


Link to post
Share on other sites

Delivi is correct you need to be specific in em's, px's, pt's or it won't display properly and the browser will trigger quirks mode on you. Although you clean up most of those errors already usually before changing DTD's you first want to burn as many of those errors as possible, and like you said going to strict is no joke since Transitional is a little looser on the rules then strict is. So you could be error free from Transitional but whined up with about 100 errors in strict.Also if you plan to go tables design your tables in CSS, pain as a but that will be it will cut down on the mixing of CSS between the actual html file and the CSS style sheet.

Share this post


Link to post
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...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.