/    Sign up×
Community /Pin to ProfileBookmark

How to remove vertical distance between 2 headings in a web page

Hi. I have a Web page called index.php. On this page there is a search box where the user searches for property. This is a practice website where I’m learning web development.

In this div I have 2 headings, h3 for title 1 and h5 for title 2 and below is a table for textboxes and a submit button. I have attached the image. [ATTACH]16617[/ATTACH]

In this image you see the distance between first 2 rows. This distance still exists, if I put them out of table.

[B]Question:[/B]
How to remove this distance like the second image, I have attached. [ATTACH]16619[/ATTACH].

This is my html code:

[CODE]<div id=”body-left1″>

<table border=”0″ id=”tbl_find”>

<tr>
<td colspan=”2″> <h3> Find Your House </h3> </td>
</tr>

<tr>
<td colspan=”2″> <h5> 3 Million Properties </h5> </td>
</tr>

<tr>
<td width=”100px”><label>City </label></td>
<td><input type=”text” name=”pCity” placeholder=”City Name”></td>
</tr>

<tr>
<td><label>Property</label></td>
<td><input type=”text” name=”pType” placeholder=”Property Type”></td>
</tr>

<tr>
<td><label>Marla</label></td>
<td><input type=”text” name=”pMarla” placeholder=”How Many Marlas”></td>
</tr>

<tr>
<td><label>Price From</label></td>
<td><input type=”text” name=”pMaxPrice” placeholder=”Maximum Price”></td>
</tr>

<tr>
<td><label>Price To</label></td>
<td><input type=”text” name=”pMinPrice” placeholder=”Minimum Price”></td>
</tr>

<tr>
<td colspan=”2″ align=”center”><br><input type=”submit” name=”search” value=”Search”></td>
</tr>
</table>
</div>[/CODE]

As i am new to web development, I have tried to use code in css.

[CODE]#body-left1
{
float: left;
width: 300px;
height: 250px;
margin: 10px 0px;
background: #EEEEEE;
}

#tbl_find
{
padding-left: 10px;
}

.h3
{
color: #E67621;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif;
padding: 0px 0px 0px 10px;
margin-top: 10px;
margin-bottom: -20px;
}

#h5
{
font-size: 15px;
padding: 10px 0px 10px 15px;
margin-bottom: -3px;
margin-bottom: -10px;
color: #666;
}
[/CODE]

Please guide me that how to do this.

[canned-message]attachments-removed-during-migration[/canned-message]

to post a comment
CSS

8 Comments(s)

Copy linkTweet thisAlerts:
@jedaisoulMar 16.2015 — In your CSS ".h3" and "#h5" should be just "h3" and "h5" respectively. Also the "margin-bottom" setting I have highlighted in red should probably be "margin-top":
<i>
</i>h3
{
padding: 0 0 0 10px;
margin-top: 10px;
margin-bottom: -20px;
}

h5
{
padding: 10px 0 10px 15px;
margin-[color=red]bottom[/color]: -3px;
margin-bottom: -10px;
}
Copy linkTweet thisAlerts:
@kmoinuMar 17.2015 — Yup, get rid of that . and # and change it to this:

[code=html]h5
{
font-size: 15px;
padding: 10px 0px 10px 15px;
margin-top: 10px;
margin-bottom: 0;
color: #666;
}[/code]
Copy linkTweet thisAlerts:
@kmoinuMar 17.2015 — Sorry, I haven't figured out how to edit my messages yet. I meant this:

[code=html]h5
{
font-size: 15px;
padding: 10px 0px 10px 15px;
margin-top: 10px;
color: #666;
}[/code]
Copy linkTweet thisAlerts:
@AdqusitauthorMar 17.2015 — @jedaisoul

What i want is that i don't want to use the values in minus(negatives). I mean is it the right way?

secondly, when i get faced with such kind of problems so I cannot handle this distance. How do i remove it. Its still not helping.


@komainu

It solved half of my problem. but h3 is still having same wrong placement.

Secondly, I don't know that sometimes margin works and sometimes padding works. Which one to use?
Copy linkTweet thisAlerts:
@jedaisoulMar 17.2015 — If yoou don't want to have a margin between the headings, and don't want to use negatives, then remove the positive spaces. I.e. Amend my code:

<i>
</i>h3
{
padding: 0 0 0 10px;
margin-top: 10px;
margin-bottom: -20px;
}

h5
{
padding: 10px 0 10px 15px;
margin-bottom: -3px;
margin-bottom: -10px;
}

To:
<i>
</i>h3
{
padding: 0 0 0 10px;
margin-top: 0;
margin-bottom: 0;
}

h5
{
padding: 0 0 0 15px;
margin-top: 0;
margin-bottom: 0;
}


Note: You may be able to simply delete the margin settings, if you have implemented the "general reset" from the beginning of my CSS code...
Copy linkTweet thisAlerts:
@AdqusitauthorMar 18.2015 — Well, its little helping, but the distance is still there. I don't know why i can't see those images which i attached with this thread, that i could show you that what i need is two texts closer to each other.

Verify my idea please if I am not wrong that this code you provided is uses to remove all the vertical spaces comes in with <h1 to h3> tags and with <p> tags. Is it right?

And can i use this way of removing spaces anywhere, where i need same feature.?

And why I can't see my images, which i provided for this thread?

Thanks
Copy linkTweet thisAlerts:
@jedaisoulMar 18.2015 — Please answer my question: Have you implemented the "general reset" I gave at the start of the CSS <style> section? I'll repeat it here for clarity:
<i>
</i>/*** general reset ***/
* {
margin:0;
padding:0;
border:none;
}
input, select {
border:1px solid grey;
}

That should be put at the start of the CSS code to remove spurious spaces caused by the browser default settings. Anything left is in your code!
Copy linkTweet thisAlerts:
@AdqusitauthorMar 19.2015 — @jed

In Post # 2 you said that In your CSS ".h3" and "#h5" should be just "h3" and "h5" respectively[/quote]

[B]Q1.[/B] Please tell me that if I use the code like this: "h3" and "h5", so it will be effecting the entire of my page? Is it right?

[B]2ndly,[/B] in last post, you mentioned First time a code to put it at the top of my css page and i complied it and put it the very first line of code in my css.

<i>
</i>* {
margin:0;
padding:0;
border:none;
}


It solved my problem.

As a supermoderator

[B]Q3[/B] why i can't view my images which i uploaded with this thread?

Thanks
×

Success!

Help @Adqusit spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...