CSS2 and XHTML strict

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
It's like the W3C's sole purpose is to make making websites harder each time a standard comes out. I must be real dumb...I can't figure out how to have two columns on a website, and have the 2nd column have all of its contents aligned to the right. div align=right works but of course that's not XHTML strict. P.S. I have spent 3 hours on this problem so far. I detest using tables.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Meh, tables are easy and work almost universally in any modern browser. I don't see what the big deal is.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
You shouldn't even be using tables if you bother to strictly adhere to xHTML/CSS. I know xHTML strict doesn't mean that you must NOT use tables, but I've never seen a website the validates xHTML strict and use tables for layout at the same time. What you want is to float one of the columns, and adjust the margin of the other (negative margins could work too).
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Originally posted by: stndn
div align=right is not valid XHTML-Strict attribute
as a general rule, most thing that controls layout (align, valign, etc) are not valid HTML Strict
You should move to style/CSS for that

div style="text-align: right" is valid
div align="right" is not valid

here's another reference
and another

Isn't that what I said in my original post? Anyway div style="text-align: right" works in IE, but Firefox is a pain in the ass. Thanks for the handy references...now I know XHTML limits childs as well...it just gets more complicated and complicated...and all I'm trying to do is make my website something standard. :( Know of any freeware (or even shareware?) XHTML editors (that generate fully compliant XHTML transitional or strict)?
 

dukdukgoos

Golden Member
Dec 1, 1999
1,319
0
76
CSS is easy, it's just a different way of thinking, but it's much simpler than tables once you get used to it. The CSS Wiki is your friend: link
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
<style type="text/css">
#right{text-align: right;}
</style>

<div id="right"></div>
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Originally posted by: notfred
<style type="text/css">
#right{text-align: right;}
</style>

<div id="right"></div>

text-align is not meant for aligning block elements, but more for aligning text much like what you do in Word (left, right, justify etc). text-align to align blocks probably only works in IE, but not on standards-compliant browsers. I think there really isn't a one-line code to do this for block elements yet, but code to ease layout is in the works for CSS3.

You should also name your divs according to the content, not the layout. eg. <div id="navigation"> instead of <div id="left">, <span class="highlight"> instead of <span class="blue">. Not super great examples but you get the idea.

Make sure you get your doctypes right, and make sure that IE is rendering in standards mode instead of quirks mode. It is very important to keep your layout consistent across different browsers. I'm saying this because IE has this "feature" where if you have a XML prolog right before the doctype, it will render the page in quirks mode.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: screw3d
Originally posted by: notfred
<style type="text/css">
#right{text-align: right;}
</style>

<div id="right"></div>

text-align is not meant for aligning block elements, but more for aligning text much like what you do in Word (left, right, justify etc). text-align to align blocks probably only works in IE, but not on standards-compliant browsers. I think there really isn't a one-line code to do this for block elements yet, but code to ease layout is in the works for CSS3.

You should also name your divs according to the content, not the layout. eg. <div id="navigation"> instead of <div id="left">, <span class="highlight"> instead of <span class="blue">. Not super great examples but you get the idea.

Make sure you get your doctypes right, and make sure that IE is rendering in standards mode instead of quirks mode. It is very important to keep your layout consistent across different browsers. I'm saying this because IE has this "feature" where if you have a XML prolog right before the doctype, it will render the page in quirks mode.

He said he wanted to align the CONTENTS of his div to the right, not the div itself.

And why the fvck would I put an id of "navigation" in a two line example on a forum? The only thing I know about this div is that he wants it to have right-aligned text, so I called it "right". You can call it "navigation" if you want, regardless of whether or not the content he's putting in it is actually used for navigation, but that would be stupid.
 

Kev

Lifer
Dec 17, 2001
16,367
4
81
Not even W3C recommends XHTML strict. I don't know why you would be using it.
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Originally posted by: notfred
Originally posted by: screw3d
Originally posted by: notfred
<style type="text/css">
#right{text-align: right;}
</style>

<div id="right"></div>

text-align is not meant for aligning block elements, but more for aligning text much like what you do in Word (left, right, justify etc). text-align to align blocks probably only works in IE, but not on standards-compliant browsers. I think there really isn't a one-line code to do this for block elements yet, but code to ease layout is in the works for CSS3.

You should also name your divs according to the content, not the layout. eg. <div id="navigation"> instead of <div id="left">, <span class="highlight"> instead of <span class="blue">. Not super great examples but you get the idea.

Make sure you get your doctypes right, and make sure that IE is rendering in standards mode instead of quirks mode. It is very important to keep your layout consistent across different browsers. I'm saying this because IE has this "feature" where if you have a XML prolog right before the doctype, it will render the page in quirks mode.

He said he wanted to align the CONTENTS of his div to the right, not the div itself.

And why the fvck would I put an id of "navigation" in a two line example on a forum? The only thing I know about this div is that he wants it to have right-aligned text, so I called it "right". You can call it "navigation" if you want, regardless of whether or not the content he's putting in it is actually used for navigation, but that would be stupid.

Chill man.. what's with the hostility? :( I'm not criticizing your example, and I really do respect the stuff that you did on your website. I'm just giving a general heads-up to OP on good naming convention. nav for left is just as a very typical example to make it easier to visualize.

I think the OPs wording are a bit misleading.. anyways here what I did according to what I *think* the OP wants. Just one of many was to do it using CSS.

I'm aware of that all these standards evangelism stuff can get absurd sometimes (which what I probably sounded like), but some of it DO make sense!