English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a specific situation that requires me to reduce my CSS stylesheet to XHTML. Rather than an admonishment about "why" I shouldn't, I would like advice about how to do this properly - is there a tool out there that will do this? For example, it would need to consider other directives in the stylesheet that relate to each item, etc., then combine them properly into XHTML/HTML4.

2007-10-14 07:25:03 · 2 answers · asked by Forrest A 1 in Computers & Internet Programming & Design

2 answers

You can always use any text editor's global search and replace function, e.g., replace all occurrences of

with



In XHTML and HTML 4, you call the style attribute on most elements.

Since XHTML is extensible, you could always use a DTD to specifically determine how elements should render, too, although it sounds like your project would not allow that, either.

You can always have your CSS inline in the document's HEAD, too, although I am sure you know that:



Finally, note that certain formatting tags, such as CENTER, and certain attributes, such as ALIGN, are deprecated in HTML 4 and removed from XHTML (although by design, again, you could make CENTER tags and define ALIGN attributes in XHTML).

2007-10-14 07:36:27 · answer #1 · answered by Anonymous · 0 0

Color me confused, XHTML is the document, CSS is the style applied to that document! The two work hand in hand to render the output to a page design. They are not inclusive of each other. A properly formed document can well and should be xhtml. It wont change the style sheet one bit nor will changing the style sheet change the document it will only change the way the document looks.

To see what I mean start here.
http://www.w3.org/TR/xhtml1/#xhtml

the following is valid xhtml

This is a paragraph.

lower case tags / on the ending one all tags have to be closed.

If I wanted to apply a style

This is a paragraph.

(notice NO change)

or

This is a paragraph

is also valid xhtml..

The someclass is an element in the style sheet, either linked or attached. The document is still valid xhtml even if the someclass style does not even exist in the style sheet!!!!

In fact, properly formed xhtml will still show as valid xhtml even with NO STYLE applied. It might look bad but it will still validate.

The following elements are NOT valid xhtml



But they become valid with




You will notice that all you have to do to have valid xhtml is use the proper tags for the HTML the style is a different issue and a document may well validate as xhtml even if the style sheet is invalid!
.
If you want to check a document for valid xhtml use
http://validator.w3.org/#validate-by-upload
it will tell you what isn't correct. (Be sure an put the document type you desire like
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
to validate it as what you want.

For CSS validation you use
http://jigsaw.w3.org/css-validator/

Notice these are separate validations!

This keeps your "content" separate from your style! That was the main idea behind CSS in the first place. In fact I usually program a page with the content

header

Intro


Another paragraph

subheader

Intro

Still another paragraph>
etc. (it just runs down the page) and then develop the style sheet to make that content appear as I want it to show. That way simply changing the style is a separate issue to the content period.

If what you are saying is you need to convert all a style sheet to full INLINE Styles just copy the proper tags to each items tag statement. Don't know of any program that will do that for you it has to be by hand as far as I know.

This is white on black but not on Yahoo

it is still valid xthml.

ADDED

I did find you a tool but I understand it may choke on complex pages?
It converts CSS styles to inline styles for email but that should be a standard page with inline.
http://www.soldesignco.com/dev-csstoinline.php

2007-10-14 08:11:45 · answer #2 · answered by Tracy L 7 · 0 0

fedest.com, questions and answers