How do I vertically position text using DIV tags?

Posted on 2008-11-01
Last Modified: 2011-10-03
On this page:

I want to move the text that says "Search Flag Football" down about 8 px so that it lines up with the top of the image scroller's black border on the left. I've tried using tables and that screwed everything up so I'm now trying to do it using DIV tags. Here's the relevant code and the rest is attached. Thanks.

.style2 {
      font-family: Arial, Helvetica, sans-serif;
      font-weight: bold;
      font-size: 10px;
      color: #FFFFFF;
      top: 50%;


        <td width="248" align="left" valign="top"><div><span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;Search Flag Football</span></div>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">


A { text-decoration:none;}

A:link	{color:blue;}

A:hover	{color: red;}

A:visited {color:blue;}

 .tab {font-size:12px;font-family:Arial,Helvetica;color:#CCCCCC;}

 .tabb {font-size:14px; font-family:Arial,Helvetica;}

body {

	font: 100% Verdana, Arial, Helvetica, sans-serif;

	background: #666666;

	margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */

	padding: 0;

	text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */

	color: #000000;


.oneColFixCtrHdr #container {

	width: 780px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */

	background: #FFFFFF;

	margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */

	border: 1px solid #000000;

	text-align: center; /* this overrides the text-align: center on the body element. */


.oneColFixCtrHdr #header {

	padding: 0 0px 0 0px;  /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */

	text-align: center;

	background-color: #000C60;


.tophalf {

	background-image: url(images/tophalfbbg.jpg);

	background-repeat: repeat-x;


a:link {

	color: #CCCCCC;


.picscroll {

	padding-top: 0px;

	padding-bottom: 0px;

	padding-left: 0px;

	margin-top: 10px;

	margin-bottom: 10px;

	margin-left: 6px;

	border-top-width: 6px;

	border-right-width: 4px;

	border-bottom-width: 6px;

	border-left-width: 4px;

	border-top-color: #000000;

	border-right-color: #000000;

	border-bottom-color: #000000;

	border-left-color: #000000;

	border-top-style: solid;

	border-right-style: solid;

	border-bottom-style: solid;

	border-left-style: solid;


.oneColFixCtrHdr #header h1 {

	margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */

	padding: 0px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */


.oneColFixCtrHdr #mainContent {

	padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */

	background: #FFFFFF;


.oneColFixCtrHdr #footer {

	padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */



.oneColFixCtrHdr #footer p {

	margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */

	padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */


.style2 {

	font-family: Arial, Helvetica, sans-serif;

	font-weight: bold;

	font-size: 10px;

	color: #FFFFFF;

	top: 50%;







*   This notice may not be removed 


//-- Begin Scroller's Parameters and message -->

//scroller width: change to your own;

var wwidth=770;

//scroller height: change to your own;

var wheight=20;

//background color: change to your own; 

var wbcolor="#ccffcc";

//scroller's speed: change to your own;

var sspeed=2;

var restart=sspeed;

var rspeed=sspeed;

//text: change to your own

wwholemessage='<nobr class=tab><b>News Scroller Horizontal v2.2 => '+

'<a class=tabb href="">'+

'Vertical Scroller JavaScript 7.0 + Horizontal Scroller JavaScript 7.0 + Typewriter Scroller JavaScript 5.0</a> <= Text Scroller Horizontal v2.2</b></nobr>';

//-- end Parameters and message-->

//-- begin: Scroller's Algorithm -->

var sizeupw=0;var operbr=navigator.userAgent.toLowerCase().indexOf('opera');if(operbr==-1&&navigator.product&&navigator.product=="Gecko"){var agt = navigator.userAgent.toLowerCase();var rvStart = agt.indexOf('rv:');var rvEnd = agt.indexOf(')', rvStart);var check15 = agt.substring(rvStart+3, rvEnd);if(parseFloat(check15)>=1.8) operbr=0;}if (navigator.appVersion.indexOf("Mac")!=-1)operbr=0;

function goup(){if(sspeed!=rspeed*8){sspeed=sspeed*2;restart=sspeed;}}

function godown(){if(sspeed>rspeed){sspeed=sspeed/2;restart=sspeed;}}

function startw(){if(document.getElementById)ns6marqueew(document.getElementById('wslider'));else if(document.all) iemarqueew(wslider);else if(document.layers)ns4marqueew(document.wslider1.document.wslider2);}function iemarqueew(whichdiv){iedivw=eval(whichdiv);"px";iedivw.innerHTML='<nobr>'+wwholemessage+'</nobr>';sizeupw=iedivw.offsetWidth;ieslidew();}function ieslidew(){if(>=sizeupw*(-1)){"px";setTimeout("ieslidew()",100);}else{"px";ieslidew();}}function ns4marqueew(whichlayer){ns4layerw=eval(whichlayer);ns4layerw.left=wwidth;ns4layerw.document.write('<nobr>'+wwholemessage+'</nobr>');ns4layerw.document.close();sizeupw=ns4layerw.document.width;ns4slidew();}function ns4slidew(){if(ns4layerw.left>=sizeupw*(-1)){ns4layerw.left-=sspeed;setTimeout("ns4slidew()",100);}else{ns4layerw.left=wwidth;ns4slidew();}}function ns6marqueew(whichdiv){ns6divw=eval(whichdiv);"px";ns6divw.innerHTML='<nobr>'+wwholemessage+'</nobr>';sizeupw=ns6divw.offsetWidth;if(operbr!=-1){document.getElementById('operaslider').innerHTML='<nobr>'+wwholemessage+'</nobr>';sizeupw=document.getElementById('operaslider').offsetWidth;}ns6slidew();}function ns6slidew(){if(parseInt(>=sizeupw*(-1)){"px";setTimeout("ns6slidew()",100);}else{"px";ns6slidew();}}

//-- end Algorithm -->


<!-- End of Script between <head> & </head> tags-->

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>


<body class="oneColFixCtrHdr"; onload="startw(); document.getElementById('wslider') = '10%';">

<div id="container">

  <div id="header" align="center">

<!-- You may remove first cell below (<td> ... </td>) to get rid of Speed-change -->

<script language="JavaScript">document.write('<table align="center" border="0"><tr><td width='+wwidth+'px>');if(document.getElementById || document.all){document.write('<span style="width:'+wwidth+'px;"><div style="position:relative;overflow:hidden;width:'+wwidth+'px;height:'+wheight+'px;clip:rect(0 '+wwidth+'px '+wheight+'px 0);background-image: url(images/topbar.jpg);" onMouseover="sspeed=0;" onMouseout="sspeed=restart">');if(operbr!=-1)document.write('<div id="operaslider" style="position:absolute;visibility:hidden;"></div>');document.write('<div id="wslider" style="position:absolute;height:'+wheight+'px;"></div></div></span>')}</script>

<ilayer width=&{wwidth}; height=&{wheight}; name="wslider1" bgcolor=&{wbcolor};><layer name="wslider2" width=&{wwidth}; height=&{wheight}; onMouseover="sspeed=0;" onMouseout="sspeed=restart"></layer></ilayer></td></tr></table>

<!-- end  of code between BODY TAGS -->


  <div align="center" class="tophalf">

    <table width="774" height="90" border="0" id="tophalf">



        <td width="515"><script type="text/javascript">

AC_FL_RunContent( 'codebase',',0,28,0','width','500','height','60','class','picscroll','src','PicStrip','quality','high','pluginspage','','bgcolor','#000000','movie','PicStrip' ); //end AC code



          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,28,0" width="500" height="60" class="picscroll">

            <param name="movie" value="PicStrip.swf" />

            <param name="quality" value="high" /><param name="BGCOLOR" value="#000000" />

            <embed src="PicStrip.swf" width="500" height="60" quality="high" pluginspage="" type="application/x-shockwave-flash" bgcolor="#000000"></embed>



        <td width="248" align="left" valign="top"><div><span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;Search Flag Football</span></div>

          <br /><form method="get" action="">


                  <input type="text" name="q" size="16" maxlength="255" value="" />

					<input type="submit" name="btnG" value="Search" />

					  <input type="hidden" name="sitesearch" value="" />





  <div id="mainContent">

    <h1> Main Content </h1>

    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at,  odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce  varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id,  libero. In eget purus. Vestibulum ut nisl. Donec eu mi sed turpis feugiat  feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut,  sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh.  Donec nec libero.</p>

    <h2>H2 level heading </h2>

    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>

	<!-- end #mainContent --></div>

  <div id="footer">


  <!-- end #footer --></div>

<!-- end #container --></div>



Open in new window

Question by:elliottbenzle
1 Comment
LVL 30

Accepted Solution

Steggs earned 500 total points
ID: 22858591

play with the padding-top: value

<td width="248" align="left" valign="top" style="padding-top:8px"><span class="style2">&nbsp;&nbsp;&nbsp;&nbsp;Search Flag Football</span>
          <br />

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at Browse or search based on font properties or name to find a suitable font for…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now