May 12, 2008

Need Help On Css

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > CSS (Cascading Style Sheets)

free web hosting

Need Help On Css

csp4.0
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

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


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

CODE
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?

 

 

 


Reply

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

Basic css format:
CODE
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:
CODE
p { border: 2 px solid red; }
for a 2px wide red border on Paragraph elements.

or:
CODE
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:
CODE
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...

 

 

 


Reply

csp4.0
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...

CODE
<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

CODE
<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?

Reply

delivi
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 smile.gif

CODE
<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.

Reply

kobra500
If you ever want some help with coding, I always use w3 schools!
I am actually making an external CSS generator using python. When it's finished i'll let you know

Reply

Saint_Michael
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics
Looking for css

Searching Video's for css
advertisement



Need Help On Css



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE