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

If you are not using css to format a simple webpage, how can you align something? I have tried to use align="center" but it is not valid to xhtml-strict???

2007-12-12 08:01:28 · 5 answers · asked by Mrs Moo 2 in Computers & Internet Programming & Design

5 answers

Change the "!DOCTYPE" at the top of the HTML to the html/xhtml transitional or loose. You could find the !DOCTYPE you could copy and paste into your HTML on the internet by searching.

You have !DOCTYPE strict at the top of your HTML, which enforces strict rules and it must meet standards. That is why it is strict. If you don't want to meet the standards exactly don't use strict, but use transitional or loose !DOCTYPE.

Using style="text-align: center" with the "div" or "p" is allowed under the xhtml strict standard. This is your only option if you want to use xhtml strict.

The answer to your question is that you MUST use CSS or the style artribute (which is considered CSS) if you are using xhtml strict. You can't use align="center", this goes against the standard. There is NO other way to do it. The other option is don't use xhtml strict if you want to use align="center".

Edit: Enter the following xhtml at http://validator.w3.org/#validate_by_input







Validation Test



Validation Test






This confirms that inline styles can be used with xhtml strict.

2007-12-12 08:43:25 · answer #1 · answered by nathan 3 · 1 1

HTML (and XHTML) is a language designed to describe the semantics of content, not its appearance.

The browser wars saw various presentational features added to the language, but these were mostly stripped out for the Strict variant of HTML 4.0. They weren't added back for the 4.01 bug fix, or the translation into XHTML that is XHTML 1.0.

If you want to specify presentation, then CSS is the correct tool. If you want to do it with (X)HTML (a bad idea), then you need to use a Transitional varient of it (designed for use while browsers caught up with the CSS standards, which they did to a sufficient level about half a decade ago).

Short answer: Aligning in XHTML 1.0 Strict without CSS is not possible.

2007-12-12 16:07:13 · answer #2 · answered by David D 7 · 1 1

You can't use inline styles with XHTML strict.

The answer is: don't use XHTML strict. No browser supports it properly anyway - they just render it as standard HTML. You're not losing anything by going back to HTML4.01 Transitional - which is just as much an "official" standard as HTML, if that's what's worrying you.

2007-12-13 02:32:02 · answer #3 · answered by Daniel R 6 · 1 1

If you are using an in-line style then you can do something like this:-

Here is some centered text

2007-12-12 19:43:18 · answer #4 · answered by ray_diator 7 · 1 1

You can use inline style for that element if you don't want to create a complete style sheet, or change the doctype to transitional.

2007-12-12 16:04:58 · answer #5 · answered by atruenightowl 3 · 1 2

fedest.com, questions and answers