Center tags in XHTML

windows

Guest
I am trying to center some things in my XHTML document.<br />
<br />
One is a horizontal text menu..I couldn't use the "align" tags as they aren't recognized by the W3C Validator.<br />
<br />
I also tried to do the same when centering text with an image.<br />
While both "work" it isn't considered valid.<br />
<br />
I am having a hard time finding examples on the W3C site..they seem to delight in being ambiguous.<br />
<br />
Since HTML tags differ form ones in XHTML..what tag is needed to center a small bit of text or center some text with an image, sort of like this example here:<br />
<br />
<p><br />
An image <br />
<img src =http://www.webdeveloper.com/forum/archive/index.php/"/images/xhtml.gif" align="middle" width="100" height="50"> <br />
in the text<br />
</p><br />
<br />
I also used this code to center my horizontal text menu:<br />
<center><a href=http://www.webdeveloper.com/forum/archive/index.php/"index.htm">Home</a> <span>|</span><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"photoshop.htm">Photoshop Images</a> <span>|</span> <br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"flash.htm">Flash Images</a> <span>|</span><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"pencil.htm">Pencil Images</a> <span>|</span><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"about">About this Site</a> <span>|</span><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"email.htm">E-Mail Me</a> <span>|</span><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"tips.htm">Tips</a> <span>|</span><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"links.htm">Links</a> <span>|</span></center> <br />
<br />
Some of the tags I used were from the "Master Visually HTML 4 and XHTML1" Guess they aren't accurate either.<!--content-->you can use the css version<br />
<div style="text-align:center;"><br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"index.htm">Home</a> |<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"photoshop.htm">Photoshop Images</a> |<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"flash.htm">Flash Images</a> | <br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"pencil.htm">Pencil Images</a> |<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"about">About this Site</a> |<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"email.htm">E-Mail Me</a> | <br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"tips.htm">Tips</a> | <br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"links.htm">Links</a> |</div><!--content-->for the image part:<br />
xhtml:<br />
<br />
<p class="centered"><br />
An image<br />
<img src =http://www.webdeveloper.com/forum/archive/index.php/"/images/xhtml.gif" align="middle" width="100" height="50" /><br />
in the text<br />
</p> <br />
<br />
css:<br />
<br />
.centered{<br />
margin:0px auto;<br />
text-align:center;<br />
}<br />
<br />
for the links:<br />
xhtml:<br />
<br />
<ul><br />
<li class="first"><a href=http://www.webdeveloper.com/forum/archive/index.php/"index.htm">Home</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"photoshop.htm">Photoshop Images</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"flash.htm">Flash Images</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"pencil.htm">Pencil Images</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"about">About this Site</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"email.htm">E-Mail Me</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"tips.htm">Tips</a></li><br />
<li><a href=http://www.webdeveloper.com/forum/archive/index.php/"links.htm">Links</a></li><br />
</ul><br />
<br />
css:<br />
<br />
ul{<br />
list-style-type:none;<br />
margin:0px auto;<br />
padding:0px;<br />
}<br />
ul li{<br />
display:inline;<br />
border-left:1px solid black;<br />
}<br />
ul li.first{<br />
border:0px;<br />
}<!--content-->Thanks IncaWarrior, it works AND validates..way cool! :D <br />
<br />
What about the aligning an image in text?<br />
Here is what I used:<br />
<p> This page is valid <br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"http://validator.w3.org/check/referer"><img<br />
src=http://www.webdeveloper.com/forum/archive/index.php/"images/valid-xhtml11.gif" align="middle"<br />
alt="Valid XHTML 1.1!" height="31" width="88" /></a><br />
</p> <br />
<br />
Can a div tag be used there too and how since the text is in front of the image?<!--content-->Oops..nevermind..thanks Samij..both XHTML and CSS are needed at the same time, eh?<br />
<br />
Okay..thanks a bunch you guys....I know it seems like a dippy question but I just do not know these things. Thanks. ;)<br />
<br />
Samij..thanks..but also what I am looking for is to center the text along the image...y'know...ummm..the test is aligned with the center of the image....can the same div tag be used just for the text or does that get really messy?<!--content-->glad to help...<br />
Not that you should use an unordered list for a nav, as that's all a nav really is (an unordered list of links). (see my example above)<!--content-->except you wouldn't use a list on a horizontal text menu<!--content-->yes, you would:<br />
<!-- m --><a class="postlink" href="http://www.ryanbrill.com">http://www.ryanbrill.com</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.alistapart.com">http://www.alistapart.com</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.zeldman.com">http://www.zeldman.com</a><!-- m --><br />
note the source code<!--content-->I tried it with both the <li> tags and the <span> tags..I just got bulleted and underlined lists...:D<!--content-->full source?<br />
and you did apply the css I gave with the example, correct?<!--content-->I did now..I forgot the CSS...so I got your code Samij and IncaWarriors. Looks really cool..I'll be back in a min..gonna go get it validated.<br />
<br />
Cool! It validates too...wasn't sure with all the code combos..thanks.<br />
<br />
Umm...I hate to be pushy but what about the issue of center aligning text with an image?<!--content-->my code didn't do that?<!--content-->Well..it didn't quite do what I needed.<br />
<br />
Here is what I had originally:<br />
<p> This page is valid <br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"http://validator.w3.org/check/referer"><img <br />
src=http://www.webdeveloper.com/forum/archive/index.php/"images/valid-xhtml11.gif" align="middle" <br />
alt="Valid XHTML 1.1!" height="31" width="88" /></a> <br />
</p><br />
<br />
<br />
You can copy it into a html doc to see what I mean...I don't know yet how to add an attachment that opens into a HTML doc yet.<br />
<br />
I guess the "align="middle" is a deprecated tag.<!--content-->and whats the goal there? text centered image not? image centered text not? both centered?<!--content-->Here is what I am trying to do..providing it works, that is.<!--content-->Originally posted by IncaWarrior <br />
except you wouldn't use a list on a horizontal text menu As samij586 said, it doesn't matter how it is layed out on your page (vertically or horizontally), it should be a list either way. This is why CSS is so useful - it allows us to use the (X)HTML tags for what they were originally meant for - markup.<!--content-->So what's the problem?<!--content-->
 
Back
Top