Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you have negative values for margins? 1

Status
Not open for further replies.

okpeery

Instructor
Dec 29, 2005
102
US
I have a top and bottom margin on both the h2 and p elements set to 0 in my style sheet and that still did not get the paragraph close enough to the heading. I gave it a negative value and got it right up under the heading as I wanted. I couldn't find out whether this was non-standard or not. Is there a better way to do it?

Also instead of the <br> tags for my listings of my universities and certifications is there a better way? When I say better I mean more standards conforming.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>

<head>
	<title>Owen Peery: Education</title>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
		<meta name="generator" content="HAPedit 3.1">


<link rel="stylesheet" type="text/css" href="niftyCorners.css">
<link rel="stylesheet" type="text/css" href="niftyPrint.css" media="print">
<link rel="stylesheet" type="text/css" href="resumestyle.css">

<script type="text/javascript" src="nifty.js"></script>
<script type="text/javascript">
window.onload=function(){
if(!NiftyCheck())
    return;
Rounded("div#content","all","#B0BFC2","#BBDB88","smooth");
Rounded("div#nav","tl bl","#B0BFC2","#FACD8A","smooth");
}
</script>

</head>

<body>
	<div id="container">
		<div id="nav">
			
				<ul>
        			<li><a href="index.html">Home</a></li>
        			<li><a href="education.html">Education</a></li>
        			<li><a href="workexperience.html">Work Experience</a></li>
        			<li><a href="relatedexperience.html">Related Experience</a></li>
        			<li><a href="technologyskills.html">Technology Skills</a></li>
        		</ul>
			
		</div>
		<div id="content">
				<h1>Owen Peery
				</h1>
		
	
				<h2>
        			Education
        		</h2>
        		<p>	
        			University of California at Berkeley<br>
					BA in History, minor in City Planning<br>
					graduated 1993
				</p>

				<p>
					Holy Names College<br>
					CA teaching credential, MA in Urban Education, ABT<br>
					Thesis currently being researched<br>
					attended 1998-2002
				</p>

				<p>
					University of the Arts<br>
					Continuing Education<br>
					Design courses: Photoshop and Web Design levels 1 and 2,<br>
					attended 2004-2006
				</p>
					
				<p>
					PTEC - Continuing Education and Professional Development<br>
					Intro and Intermediate level courses: Word, Excel, and Powerpoint<br>
					Intro to iPhoto and iTunes<br>
					Netrekker<br>
					Schoolnet
				</p>
        		
        		<h2>
        			Certifications
        		</h2>
        		<p>
        			PA Elementary Education, 2005<br>
        			PA Business, Computers, Information Technology, 2005<br>
        			PA Master's Equivalency, 2005<br>
        			CA Elementary Education, 2002<br>
        			CA Supplemental Authorization for Social Studies, 2002<br>
        		</p>
	
	</div>
</div>

</body>

</html>

CSS:
Code:
				body
				{
				padding: 20px;
				background-color: #B0BFC2; 
				text-align: center;
    			font: 95% Verdana,Arial,sans-serif;
    			}

				h1
				{
				font-size: 250%;
				color: #FFF;
				letter-spacing: 1px;
				margin: 0;
				padding: 0 0 10px 10px;
				}

				h2
				{
				font-size: 150%;
				color: #FFF;
				margin: 0;
				margin-bottom: -10px;
				padding: 0 0 10px 10px;
				}
				
				p
				{
				margin: 0;
				padding: 0 0 10px 10px;
				}

				div#container
				{
				width:700px;
				margin: 0 left;
				text-align:left;
				}

				div#content
				{
				float:right;
				width:515px;
				background: #BBDB88;
				}

				div#nav
				{
				float:left;
				width:180px;
				margin-top:40px;
				background: #FACD8A;
				}
				
				#nav ul
        		{
        		margin: 10px;
        		padding: 0;
        		list-style-type: none;
        		text-align: right;
        		line-height: 250%;
        		}
        		
        		
        		a
        		{
        		text-decoration: none;
        		}
        		
        		a:link
        		{
        		color: black;
        		}
        		
        		a:visited
        		{
        		color: black;
        		}
        		
        		a:hover
        		{
        		color: orange;
        		}
 
Negative margins are perfectly acceptable and if they give you the effect you were looking for (sort of overlaying effect) than you should use it. Just make sure it looks ok on all browsers.

As for your second question:
okpeery said:
Also instead of the <br> tags for my listings of my universities and certifications is there a better way? When I say better I mean more standards conforming.
You've answered your own question. For listings, use lists. Be it definition lists, ordered or unordered lists. Whichever fit best.
 
Incidentally, if I use the shorthand margin statement

margin: 0 -10px 0 0

I don't get the effect I wanted but when I use

margin: 0;
margin-bottom: -10px;

I get the effect, at least in FF for now. Why?

Back to the <br> tags
I should use an unordered list, with text decoration none, and each line will be a list item? Yes It is a listing of universities and certifications but a simple list won't give me the breaks where I want them. Use list item tags where I want the breaks?
 
First, margin. Shorthand property when giving four values works like this. You begin with top, then set the others in a clockwise fashion. Like so:
Code:
margin: top right bottom left;
So you're setting right margin to -10px in your first example, not the bottom one.

Second, the br tags. I am thinking maybe you could go with the definition lists. Here's a good page describing (and showing) different way you can style those.
 
Of course, I don't know why I thought otherwise for the order.

I also already changed the html and styled it for a ul list. I looked at the dl link and maybe I'll change it to that but for now this works.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top