Freelancer.com

Go Back   Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming
Register Blogs Social Groups Advertise with usHelp Desk

Reply
LinkBack Thread Tools
Unread 6th March 2014, 06:13 AM   #1
Active Warrior
 
Join Date: 2014
Posts: 93
Thanks: 198
Thanked 7 Times in 5 Posts
Default How to reduce the space between H1 and H2 in css.

I can't for the life of me figure out how to reduce the space of h1 and h2 within a div. I've tried setting the margin and padding to 0 but nothing changes. I'm working through a tutorial on Lynda.com and I'm playing around with the code of one of the lessons.

Here's the code.

Code:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>box-model</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
aside, article, section, header, footer, nav {
	display: block;
}
div, p {
	margin: 0;
	padding:0;
}
html {
	background: #ccc;
}
.outer {
	width: 400px;
	height: 1000px;
	margin: 0;
	background: #9CF;
	padding: 1px;
}
.box{
	
}
p {
	background: #EEA458;
	height: 100%;
	margin: 0;
	padding: 0;
}
	
/*add styles here*/
<h1> { 
padding: 0;
margin: 0;
}

h2 { 
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div class="outer">

<div class="box">
<p>The box model describes the physical properties of each element on your page. Margins, borders, padding, and content all make up an element's box. In this case, the inner div tag's margins can be seen with the blue color, the border is black, the padding is represented by orange, and the element's width and height are yellow.
</p>
</div>
<h1>This is a head.  I want eliminate the space between this and the h2</h1>
<h2>Some text<h2>
</div>
</body>
</html>
-edit- I found the error. I put <> around the h1 in the css, so it didn't recognize it.

I'm still having problems with a site I'm developing with the same problem. So I will probably come back to this thread with my problem there if I can't figure it out.
NateJasper is offline   Reply With Quote
Unread 6th March 2014, 06:53 AM   #2
Active Warrior
 
Join Date: 2014
Posts: 93
Thanks: 198
Thanked 7 Times in 5 Posts
Default Re: How to reduce the space between H1 and H2 in css.

Ok, I still can't reduce the spacing between the H1 and H2 in the site I'm developing.

I'm using the two column template from dreamweaver and I'm working on the header. I want to reduce the space between the text in the header.

Here's the html.

Code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="main.css" rel="stylesheet" type="text/css"><!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

<body>

<div class="container">
  <header>
    <img src="_images/bankseal.png" alt="Bank on Yourself Authorized Advisor" width="200" height="204" id="Insert_logo"  />
    <img src="_images/fred175b175.png" alt="Fred Lewis" id="FredPhoto" />
    <h1 id="headerLine1">FRED LEWIS FINANCIAL</h1>
   <h2 id="headerLine2">SAFETY, RETURN, TAXES</h2>
   
   
  </header>
  <div class="sidebar1">
  <nav>
    <ul>
      <li><a href="#">Link one</a></li>
      <li><a href="#">Link two</a></li>
      <li><a href="#">Link three</a></li>
      <li><a href="#">Link four</a></li>
    </ul>
    </nav>
    <aside>
      <p> The above links demonstrate a basic navigational structure using an unordered list styled with CSS. Use this as a starting point and modify the properties to produce your own unique look. If you require flyout menus, create your own using a Spry menu, a menu widget from Adobe's Exchange or a variety of other javascript or CSS solutions.</p>
      <p>If you would like the navigation along the top, simply move the ul to the top of the page and recreate the styling.</p>
    </aside>
  <!-- end .sidebar1 --></div>
  <article class="content">
    <h1>Instructions</h1>
    <section>
     <h2>How to use this document</h2>
      <p>Be aware that the CSS for these layouts is heavily commented. If you do most of your work in Design view, have a peek at the code to get tips on working with the CSS for the fixed layouts. You can remove these comments before you launch your site. To learn more about the techniques used in these CSS Layouts, read this article at Adobe's Developer Center - <a href="http://www.adobe.com/go/adc_css_layouts">http://www.adobe.com/go/adc_css_layouts</a>.</p>
    </section>
    <section>
      <h2>Clearing Method</h2>
      <p>Because all the columns are floated, this layout uses a clear:both declaration in the footer rule.  This clearing technique forces the .container to understand where the columns end in order to show any borders or background colors you place on the .container. If your design requires you to remove the footer from the .container, you'll need to use a different clearing method. The most reliable will be to add a &lt;br class=&quot;clearfloat&quot; /&gt; or &lt;div  class=&quot;clearfloat&quot;&gt;&lt;/div&gt; after your final floated column (but before the .container closes). This will have the same clearing effect. </p>
    </section>
    <section>
      <h2>Logo Replacement</h2>
      <p>An image placeholder was used in this layout in the header where you'll likely want to place  a logo. It is recommended that you remove the placeholder and replace it with your own linked logo. </p>
      <p> Be aware that if you use the Property inspector to navigate to your logo image using the SRC field (instead of removing and replacing the placeholder), you should remove the inline background and display properties. These inline styles are only used to make the logo placeholder show up in browsers for demonstration purposes. </p>
      <p>To remove the inline styles, make sure your CSS Styles panel is set to Current. Select the image, and in the Properties pane of the CSS Styles panel, right click and delete the display and background properties. (Of course, you can always go directly into the code and delete the inline styles from the image or placeholder there.)</p>
    </section>
    <section>
      <h2>Backgrounds</h2>
      <p>By nature, the background color on any block element will only show for the length of the content. This means if you're using a background color or border to create the look of a side column, it won't extend all the way to the footer but will stop when the content ends. If the .content block will always contain more content, you can place a border on the .content block to divide it from the column.</p>
    </section>
    <!-- end .content --></article>
  <footer>
    <p>This footer contains the declaration position:relative; to give Internet Explorer 6 hasLayout for the footer and cause it to clear correctly. If you're not required to support IE6, you may remove it.</p>
    <address>
      Address Content
    </address>
  </footer>
  <!-- end .container --></div>
</body>
</html>
And here's the CSS.

Code:
@charset "utf-8";
body {
	font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
	background-color: #ffffff;
	margin: 0;
	padding: 0;
	color: #000;
	
}

ul, ol, dl { 
	padding: 0;
	margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
	margin: 0;	
	padding-right: 0px;
	padding-left: 0px;
	
}
a img { 
	border: none;
}

a:link {
	color: #42413C;
	text-decoration: underline; 
}
a:visited {
	color: #6E6C64;
	text-decoration: underline;
}
a:hover, a:active, a:focus { 
	text-decoration: none;
}

.container {
	width: 960px;
	background-color: #FFFFFF;
	margin: 0 auto;
}

header {
	height: 204px;
	width: 960px;
	background: rgb(19,19,19); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(19,19,19,1) 0%, rgba(86,86,86,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(19,19,19,1)), color-stop(100%,rgba(86,86,86,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(19,19,19,1) 0%,rgba(86,86,86,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(19,19,19,1) 0%,rgba(86,86,86,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(19,19,19,1) 0%,rgba(86,86,86,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(19,19,19,1) 0%,rgba(86,86,86,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#131313', endColorstr='#565656',GradientType=0 ); /* IE6-9 */
;
}
#Insert_logo {
	float: left;
}
#FredPhoto {
	
	float: right;
	padding-left: 25px;
	padding-top: 25px;
	padding-bottom: 25px;
	
}
h1#headerLine1  {
	color: white;
	font-size: 42px;
	font-family: Arial-Bold;
	font-weight: bold;
	text-align: center;
	margin: 0px;
	padding: 0px;
	
}
h2#headerLine2 {
	color: white;
	font-family: Arial-Bold;
	font-size: 38px;
	text-align: center;
	padding: 0px;
	margin: 0px
	
	
}
/*style="background-color: #C6D580; display:block;"*/


.sidebar1 {
	float: right;
	width: 180px;
	background-color: #EADCAE;
	padding-bottom: 10px;
}
.content {
	padding: 10px 0;
	width: 780px;
	float: right;
}


.content ul, .content ol {
	padding: 0 15px 15px 40px;  
}


nav ul{
	list-style: none; /* this removes the list marker 
	margin-bottom: 15px; /* this creates the space between the navigation on the content below */
}
nav li {
	border-bottom: 1px solid #666;
}
nav a, nav a:visited { 
	padding: 5px 5px 5px 15px;
	display: block;
	width: 160px;  
	text-decoration: none;
	background-color: #C6D580;
}
nav a:hover, nav a:active, nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */
	background-color: #ADB96E;
	color: #FFF;
}


footer {
	padding: 10px 0;
	background-color: #CCC49F;
	position: relative;/* this gives IE6 hasLayout to properly clear */
	clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
}


header, section, footer, aside, article, figure {
	display: block;
}
NateJasper is offline   Reply With Quote
Unread 6th March 2014, 07:23 AM   #3
ɹoıɹɹɐʍ ǝʌıʇɔɐɹǝdʎɥ
War Room Member
 
RobinInTexas's Avatar
 
Join Date: 2008
Location: Texas
Posts: 2,143
Blog Entries: 3
Thanks: 231
Thanked 442 Times in 380 Posts
Default Re: How to reduce the space between H1 and H2 in css.

Have you tried using css negative numbers in margins/padding?

Code:
h2#headerLine2 {
margin-top:-10px;
margin-bottom: -10px;
margin-right:50px;
margin-left:50px;

}

Robin


...Even if you're on the right track, you'll get run over if you just set there.
RobinInTexas is offline   Reply With Quote
Unread 6th March 2014, 07:36 AM   #4
HyperActive Warrior
War Room Member
 
alistair's Avatar
 
Join Date: 2010
Location: England
Posts: 393
Thanks: 104
Thanked 269 Times in 191 Posts
Default Re: How to reduce the space between H1 and H2 in css.

Try #headerLine1 .h1 and #headerLine2 .h2

I'm not an expert and not sure whether it's right or wromng but it's a suggestion at least.
alistair is offline   Reply With Quote
Unread 6th March 2014, 07:57 AM   #5
Active Warrior
 
Join Date: 2014
Posts: 93
Thanks: 198
Thanked 7 Times in 5 Posts
Default Re: How to reduce the space between H1 and H2 in css.

Quote:
Originally Posted by RobinInTexas View Post
Have you tried using css negative numbers in margins/padding?

Code:
h2#headerLine2 {
margin-top:-10px;
margin-bottom: -10px;
margin-right:50px;
margin-left:50px;

}
That worked. Thanks.
NateJasper is offline   Reply With Quote
Unread 6th March 2014, 11:23 PM   #6
SJL
HyperActive Warrior
War Room Member
 
SJL's Avatar
 
Join Date: 2010
Location: Finland
Posts: 130
Thanks: 11
Thanked 29 Times in 24 Posts
Default Re: How to reduce the space between H1 and H2 in css.

Quote:
Originally Posted by RobinInTexas View Post

Code:
h2#headerLine2 {
margin-top:-10px;
margin-bottom: -10px;
margin-right:50px;
margin-left:50px;

}
couple shorter ways to do this
Code:
margin:-10px 50px;
/* top&bottom right&left */
Code:
margin:-10px 50px -10px 50px;
/* top left bottom right */

SJL is online now   Reply With Quote
Reply

  Warrior Forum - The #1 Internet Marketing Forum & Marketplace > Warrior Support Forums > Programming

Bookmarks

Tags
css, reduce, space

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 12:18 AM.