Jump to content

Positioning images etc. in a page


Kimidori

Recommended Posts

Hello,I'm new to html and css so please help meHow can I position several images as links/embedded videos in the center of a page so it may look like this:

Image1 Image2 Image3 Image4

Thank you in advance.

No problem Kimidori, that's really easy.Here is code that should do that:
<center><a href="whatever_you_want_to_link_to.ext"><img src="image1"></a><a href="whatever_you_want_to_link_to.ext"><img src="image2"></a><a href="whatever_you_want_to_link_to.ext"><img src="image3"></a><a href="whatever_you_want_to_link_to.ext"><img src="image4"></a></center>

If you want to center it vertically, I suggest adding <br><br><br><br><br> on a line before that code. Each <br> will bring the images down by one line.There are probably much better ways of doing this, but that's what I use.Hope that helps,LifeInBinary.

Link to comment
Share on other sites

This would be more W3C complliant

<html><head><style>p.center{    align:center;}</style></head><body><p class="center"><a href="whatever_you_want_to_link_to.ext"><img src="image1"></a><a href="whatever_you_want_to_link_to.ext"><img src="image2"></a><a href="whatever_you_want_to_link_to.ext"><img src="image3"></a><a href="whatever_you_want_to_link_to.ext"><img src="image4"></a></p></body></html>

Link to comment
Share on other sites

No Problem :)

Link to comment
Share on other sites

Link to comment
Share on other sites

Prateek's code was slightly incorrect. change "align" to "text-align".Here is a fully w3c valid html 4.01 strict document

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><title>Page title here</title><style type="text/css">p.center{text-align:center;}</style><p class="center"><a href="whatever_you_want_to_link_to.ext"><img src="image1" alt="alternative text"></a><a href="whatever_you_want_to_link_to.ext"><img src="image2" alt="alternative text"></a><a href="whatever_you_want_to_link_to.ext"><img src="image3" alt="alternative text"></a><a href="whatever_you_want_to_link_to.ext"><img src="image4" alt="alternative text"></a></p>

Link to comment
Share on other sites

Yup the text-align works!

Link to comment
Share on other sites

Hers is another method to centre the pictures using a div and is xhtml valid.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>	<title>An XHTML 1.0 Strict standard template</title>	<meta http-equiv="content-type" 		content="text/html;charset=utf-8" />	<meta http-equiv="Content-Style-Type" content="text/css" /><style type="text/css" >div.center{margin: 0 auto;text-align:center;}</style></head><body><div class="center"><a href="whatever_you_want_to_link_to.ext"><img src="image1" alt="alt here" /></a><a href="whatever_you_want_to_link_to.ext"><img src="image2" alt="alt here" /></a><a href="whatever_you_want_to_link_to.ext"><img src="image3" alt="alt here" /></a><a href="whatever_you_want_to_link_to.ext"><img src="image4" alt="alt here" /></a></div></body></html>

Link to comment
Share on other sites

yeah you might want to use DIV instead.QUOTE(croatiankid @ Feb 28 2007, 07:12 AM) *<script type="text/javascript" src="urltoscript.js"></script> for html<script type="text/javascript" src="urltoscript.js" /> works in xhtml.Wase that supposed to be on my post?yeah lol

Link to comment
Share on other sites

Prateek's code was slightly incorrect. change "align" to "text-align"
Oh, Thanks a lot, it worked - finally! :) Thanks also to all who helped, I appreciate it ^^I want to use DIV but I'm just a beginner in this stuff, I couldn't understand much about DIV at the moment :) but I'll study about it.
Link to comment
Share on other sites

Div's will be your best friend once you get to using them. Check the html Tutorial over at w3schools.com. They are generic 'containers' and are better suited for what you are doing instead of the <p> paragraph tag. IMHO.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...