Why can I click on a link outside of its text element? - html

I'm building a forum and I have a link that can be clicked outside of its text, how can I undo it?
I also have an image inside a tag that can be clicked outside of its image, I want to undo that too.
I have tried - position: relative; but it didn't work.
Here is the HTML code of the image.
<div class="nav-list">
<a class="home_A"href="Home.php">
<img class="homeIcon" src="photos/icon.png">
</a>
</div>
CSS of the image
.homeIcon{
width: 200px;
display:block;
margin:auto;
margin: 0 auto;
}
CSS of the <a> link
.signinForm a{
margin: auto;
display:block;
text-align:center;
margin-top: 7px;
color: #006db6;
font-size: 20px;
}
HTML of the <a> link
<form method="POST" class="signinForm">
<ul>
<li> <h1 class="signinH1">sign in</h1></li>
<li> <input type="text" placeholder="User name"name="username_login"class="username" value="<?php if(isset($_POST['username_login'])){echo $_POST['username_login'];}?>" required></li>
<li> <input type="password" placeholder="Password" name="password_login" class="password" value="<?php if(isset($_POST['password_login'])){echo $_POST['password_login'];}?>" required></li>
<li> <input type="submit" value="Log in"class="signinbutton"></li>
<li>Sign up</li>
</ul>
</form>
Thanks all.

It might have to do with your CSS styles for <a> tags and/or <img> tags.
My guess is that something like the following might fix your issue
.homeIcon {
display: inline-block;
}

Try with something like:
img.homeIcon {
display: inline-block;
}
div.home_A {
align-content:center;
margin: 0 auto;
text-align: center; // Not mandatory but useful
}

Assign display: inline-block of course, also use object-fit:contain on <img> and set the line-height: of <a> to 1 to 1.25 depending on how your font is setup but there's very little play in the value.
:root {
font: 1ch/1 'Segoe UI'
}
body {
font-size: 2ch;
}
a {
font-size: 2.5rem;
line-height: 1.15;
}
a,
img {
display: inline-block;
}
img {
object-fit: contain;
width: 3rem;
height: 3rem;
margin-bottom: -3px;
}
<div class='frame'>
<a class="zOne" href="https://stackoverflow.com/users/2813224/zer00ne">
..::Zer00ne::..
<img src='https://i.ibb.co/Kx33pSY/01.jpg'></a>
</div>

<!--HTML_CODE-->
<div class="nav-list">
<a class="home_A"href="Home.php">
<img class="homeIcon" src="photos/icon.png">
</a>
</div>
<form method="POST" class="signinForm">
<ul>
<li> <h1 class="signinH1">sign in</h1></li>
<li> <input type="text" placeholder="User
name"name="username_login"class="username" value="<?php
if(isset($_POST['username_login'])){echo $_POST['username_login'];}?>" required>
</li>
<li> <input type="password" placeholder="Password" name="password_login"
class="password" value="<?php if(isset($_POST['password_login'])){echo
$_POST['password_login'];}?>" required></li>
<li> <input type="submit" value="Log in"class="signinbutton"></li>
<div class="signUp-block">
<li>Sign up</li></div>
</ul>
</form>
/*CSS_CODE*/
.homeIcon{
width: 200px;
display:block;
margin:auto;
margin: 0 auto;
}
.signUp-block{
display: flex;
flex-direction: row;
justify-content: center;
}
.signinForm a{
margin: auto;
display:inline-block;
text-align:center;
margin-top: 7px;
color: #006db6;
font-size: 20px;
}
.homeIcon {
display: inline-block;
}

Related

Access key/ keyboard shortcut doesn't work after I added the accesskey attribute. Why is that?

We are only concerned with the following snippet:
<nav>
<ul>
<li><a accesskey="s" href="#student-info">INFO</a></li>
<li><a accesskey="h" href="#html-questions">HTML</a></li>
<li><a accesskey="c" href="#css-questions">CSS</a></li>
</ul>
</nav>
I added the access keys/ shortcuts s, h, and, c to the three list items in our navigation bar. However, when I press s, h, or c, nothing happens. Isn't something supposed to happen? To elaborate, in the output, if I click on any of INFO, HTML, and CSS in the navigation bar, I will go straight to that section. Similarly, shouldn't the same thing happen if I press 's' instead of clicking on INFO in the navigation bar?
Disclaimer: Just ignore the CSS file. We are only concerned with the accesskey attribute in the anchor elements nested in the nav element.
These are my html and css files:
#media (prefers-reduced-motion: no-preference) {
* {
scroll-behavior: smooth;
}
}
body {
background: #f5f6f7;
color: #1b1b32;
font-family: Helvetica;
margin: 0;
}
header {
width: 100%;
height: 50px;
background-color: #1b1b32;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
top: 0;
}
#logo {
width: max(100px, 18vw);
background-color: #0a0a23;
aspect-ratio: 35 / 4;
padding: 0.4rem;
}
h1 {
color: #f1be32;
font-size: min(5vw, 1.2em);
text-align: center;
}
nav {
width: 50%;
max-width: 300px;
height: 50px;
}
nav > ul {
display: flex;
justify-content: space-evenly;
flex-wrap: wrap;
align-items: center;
padding-inline-start: 0;
margin-block: 0;
height: 100%;
}
nav > ul > li {
color: #dfdfe2;
margin: 0 0.2rem;
padding: 0.2rem;
display: block;
}
nav > ul > li:hover {
background-color: #dfdfe2;
color: #1b1b32;
cursor: pointer;
}
li > a {
color: inherit;
text-decoration: none;
}
main {
padding-top: 50px;
}
section {
width: 80%;
margin: 0 auto 10px auto;
max-width: 600px;
}
h1,
h2 {
font-family: Verdana, Tahoma;
}
h2 {
border-bottom: 4px solid #dfdfe2;
margin-top: 0px;
padding-top: 60px;
}
.info {
padding: 10px 0 0 5px;
}
.formrow {
margin-top: 30px;
padding: 0px 15px;
}
input {
font-size: 16px;
}
.info label, .info input {
display: inline-block;
text-align: right;
}
.info input {
width: 50%;
text-align: left;
}
.info label {
width: 10%;
min-width: 55px;
}
.question-block {
text-align: left;
display: block;
width: 100%;
margin-top: 20px;
padding-top: 5px;
}
p {
margin-top: 5px;
padding-left: 15px;
font-size: 20px;
}
p::before {
content: "Question #";
}
.question {
border: none;
padding-bottom: 0;
}
.answers-list {
list-style: none;
padding: 0;
}
button {
display: block;
margin: 40px auto;
width: 40%;
padding: 15px;
font-size: 23px;
background: #d0d0d5;
border: 3px solid #3b3b4f;
}
footer {
background-color: #2a2a40;
display: flex;
justify-content: center;
}
footer,
footer a {
color: #dfdfe2;
}
address {
text-align: center;
padding: 0.3em;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="freeCodeCamp Accessibility Quiz practice project" />
<title>Accessibility Quiz</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<header>
<img id="logo" src="https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg">
<h1>HTML/CSS Quiz</h1>
<nav>
<ul>
<li><a accesskey="s" href="#student-info">INFO</a></li>
<li><a accesskey="h" href="#html-questions">HTML</a></li>
<li><a accesskey="c" href="#css-questions">CSS</a></li>
</ul>
</nav>
</header>
<main>
<form method="post" action="https://freecodecamp.org/practice-project/accessibility-quiz">
<section role="region" aria-labelledby="student-info">
<h2 id="student-info">Student Info</h2>
<div class="info">
<label for="student-name">Name:</label>
<input type="text" name="student-name" id="student-name" />
</div>
<div class="info">
<label for="student-email">Email:</label>
<input type="email" name="student-email" id="student-email" />
</div>
<div class="info">
<label for="birth-date">D.O.B.<span class="sr-only">(Date of Birth)</span></label>
<input type="date" name="birth-date" id="birth-date" />
</div>
</section>
<section role="region" aria-labelledby="html-questions">
<h2 id="html-questions">HTML</h2>
<div class="question-block">
<p>1</p>
<fieldset class="question" name="html-question-one">
<legend>
The legend element represents a caption for the content of its
parent fieldset element
</legend>
<ul class="answers-list">
<li>
<label for="q1-a1">
<input type="radio" id="q1-a1" name="q1" value="true" />
True
</label>
</li>
<li>
<label for="q1-a2">
<input type="radio" id="q1-a2" name="q1" value="false" />
False
</label>
</li>
</ul>
</fieldset>
</div>
<div class="question-block">
<p>2</p>
<fieldset class="question" name="html-question-two">
<legend>
A label element nesting an input element is required to have a
for attribute with the same value as the input's id
</legend>
<ul class="answers-list">
<li>
<label for="q2-a1">
<input type="radio" id="q2-a1" name="q2" value="true" />
True
</label>
</li>
<li>
<label for="q2-a2">
<input type="radio" id="q2-a2" name="q2" value="false" />
False
</label>
</li>
</ul>
</fieldset>
</div>
</section>
<section role="region" aria-labelledby="css-questions">
<h2 id="css-questions">CSS</h2>
<div class="formrow">
<div class="question-block">
<label for="customer">Are you a frontend developer?</label>
</div>
<div class="answer">
<select name="customer" id="customer" required>
<option value="">Select an option</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</div>
<div class="question-block">
<label for="css-questions">Do you have any questions:</label>
</div>
<div class="answer">
<textarea id="css-questions" name="css-questions" rows="5" cols="24" placeholder="Who is flexbox..."></textarea>
</div>
</div>
</section>
<button type="submit">Submit</button>
</form>
</main>
<footer>
<address>
freeCodeCamp<br />
San Francisco<br />
California<br />
USA
</address>
</footer>
</body>
</html>
It does work, but it depends on the browser which combination is necessary to activate the access key.
Single characters keys are not a good idea, since they conflict with controls for the browser and screen readers. Hence, browsers typically require a key combination:
On Windows, it’s most likely Alt+Shift+key
And on Mac Control + Option + key
In general, there are some accessibility caveats with the accesskey attribute. See Accesskey on WebAIM
Due to numerous problems with implementation, accesskey is typically best avoided.
For some discussion on how to communicate the access keys to sighted users, see How to highlight accesskeys in a WCAG valid way?

How can I move both of my input text fields into the same row?

I'm designing my first website and I'm trying to do a tab where people can fill a form. I have two input fields for first and last name but they are on different lines.
Photo of how the form is right now
I want to move both of them side by side to the line above, beside the grey box. Basically I want to have everything on the same line.
Below is the HTML and CSS:
.Contact-Us h1 {
text-align: center;
padding-bottom: 20px;
padding-top: 10px;
}
#Start-registration {
display: flex;
border: 1px solid grey;
background-color: #DCDCDC;
margin-left: 30px;
width: 170px;
}
.First-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
.Last-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<article class="Contact-Us">
<h1> Contact Us </h1>
<p class="Subtitle-Info"> Contact us via sending a message </p>
<p id="Start-registration"> First and last name </p>
<form action="" method="get" class="First-name">
<label for='First_name'></label>
<input id='First_name' name='First_name' type='text' placeholder="First Name" />
</form>
<form action="" method="get" class="Last-name">
<label for='Last_name'></label>
<input id='Last_name' name='Last_name' type='text' placeholder="Last Name" />
</form>
</article>
You should have only 1 form like this..
.Contact-Us h1 {
text-align: center;
padding-bottom: 20px;
padding-top: 10px;
}
#Start-registration {
display: flex;
border: 1px solid grey;
background-color: #DCDCDC;
margin-left: 30px;
width: 170px;
}
.First-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
.Last-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 35%;
}
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'/>
<title>SerFin</title>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght#300&display=swap" rel="stylesheet">
<link href='../test.css' rel='stylesheet'/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$('.dropdown').hover(function(){
$('.dropdown-menu', this).stop(true, true).slideDown(0);
$(this).addClass('open');
},
function(){
$('.dropdown-menu', this).stop(true, true).slideUp(0);
$(this).removeClass('open');
});
});
</script>
</head>
<body>
<header>
<nav>
<ul class="menu">
<li>Home</li>
<li><a href='Customer-service.html'>Customer Service</a></li>
<li>About us<li>
<li><a href='#'>Submission</a></li>
<li class="dropdown">
<a class="dropdown-toggle" href="#">Search Engine <b class="caret"></b><a>
<ul class="dropdown-menu">
<li>Universities</li>
<li>Jobs</li>
<li>Courses</li>
<li>Internships</li>
<li>Services</li>
</ul>
</li>
</ul>
<ul class="setup">
<li><a href='#'>Login</a></li>
<li>Sign up</li>
</ul>
</nav>
</header>
<article class="Contact-Us">
<h1> Contact Us </h1>
<p class="Subtitle-Info"> Contact us via sending a message </p>
<p id="Start-registration"> First and last name </p>
<form action="" method="get" class="First-name">
<label for='First_name'></label>
<input id='First_name' name='First_name' type='text' placeholder="First Name"/>
<label for='Last_name'></label>
<input id='Last_name' name='Last_name' type='text' placeholder="Last Name"/>
</form>
</article>
</body>
</html>
Wrap both of them into one division like this:
<div class="main">
<form action="" method="get" class="First-name">
<label for='First_name'></label>
<input id='First_name' name='First_name' type='text' placeholder="First Name" />
</form>
<form action="" method="get" class="Last-name">
<label for='Last_name'></label>
<input id='Last_name' name='Last_name' type='text' placeholder="Last Name" />
</form>
</div>
Then style css:
.First-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 100%;
}
.Last-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 100%;
}
.main{
display:flex;
width:50%;
justify-content:space-between;
}
This will do it.
I don't know why you created a form element for each input unless you are going to submit them to different php documents
This will do it:
.Contact-Us h1 {
text-align: center;
padding-bottom: 20px;
padding-top: 10px;
}
#Start-registration {
display: flex;
border: 1px solid grey;
background-color: #DCDCDC;
margin-left: 30px;
width: 170px;
}
.First-name input[type='text'] {
font-size: 16px;
height: 34px;
width: 100%;
}
.Last-name input[type='text'] {
font-size: 16px;
height: 34px;
width:100%;
}
.the_edit {
display: flex;
justify-content:flex-start;
width:100%;
}
form {
width:35%;
}
<article class="Contact-Us">
<h1> Contact Us </h1>
<p class="Subtitle-Info"> Contact us via sending a message </p>
<div class="the_edit">
<p id="Start-registration"> First and last name </p>
<form action="" method="get" class="First-name">
<label for='First_name'></label>
<input id='First_name' name='First_name' type='text' placeholder="First Name" />
</form>
<form action="" method="get" class="Last-name">
<label for='Last_name'></label>
<input id='Last_name' name='Last_name' type='text' placeholder="Last Name" />
</form>
</div>
</article>
(You will see the desired results when you will expand the snippet)
You can play around with the styles further. The main thing to do is to wrap the contents you want in a single line inside a div and set its display to flex.

how do vertically align login form between banner and footer

Given I have the html and css in the snippet below the question, how can I vertically centre the login view no matter what screen height is?
I have tried this for the .login-layout__positioner class:
.login-layout__positioner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 42%;
transform: translateY(-42%);
}
But this does not centre well in large screen heights?
Is there a better way?
body {
height: 100%;
background-color: #f7f7f4;
}
.app-layout__body {
height: 100vh;
display: flex;
flex-direction: column;
}
.app-layout__container {
flex: 1 0 auto;
}
.banner__container {
background-color: #fff
}
.banner__top {
padding-top: 15px;
}
.login-layout__container {
background-color: #f7f7f4;
width: 100%;
}
.login-layout__positioner {
text-align: center;
margin: auto;
}
footer {
background-color: #0065bd;
}
a {
color: #fff;
}
ul {
list-style: none;
margin-left: 0;
}
li {
display: inline;
}
.form__group {
background-color: #fff;
}
<body>
<div id="root">
<div class="main-content">
<div class="app-layout__body">
<div class="app-layout__container">
<div class="banner__container">
<div class="banner__top">
<div>
<div>
<h2>Banner</h2></div>
</div>
</div>
</div>
<div class="login-layout__container">
<div class="login-layout__positioner">
<div class="form__group">
<div>
<form>
<div class="login__container">
<div class="login__wrapper">
<div>
<div>
<div class="login__form__elements">
<div>
<div>
<h2 class="">Sign In</h2></div>
</div>
<div>
<div>
<div>
<label for="email" id="email-label" class="label__default label__strong label__double-margin">Email</label>
<div>
<input type="text" autocomplete="off" class="input__default form-control" id="email" name="email" aria-invalid="false" aria-describedby="email-error" value="">
</div>
<div id="email-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div>
<div>
<label for="password" id="password-label">Password</label>
<div>
<input type="password" autocomplete="off" id="password" name="password" aria-invalid="false" aria-describedby="password-error" value="">
</div>
<div id="password-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div><a to="/">Forgotten your password?</a></div>
<div>
<button type="submit">LOGIN</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer>
<div>
<div>
<div>
<ul>
<li><a target="_blank" href="/static/about">About</a></li>
<li><a target="_blank" href="/static/accessibility">Accessibility</a></li>
<li><a target="_blank" href="/static/cookies">Cookies</a></li>
<li><a target="_blank" href="/static/privacy">Privacy</a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
</div>
</div>
</body>
When it comes to centering something both vertically and horizontally I like to use css flex. Adding it to the parent container surrounding the element you wish to center will cause it to flex in all screen dimensions and heights. Justify-content centers it horizontally and align-items centers it vertically. Here is a helpful guide to learn more about flex:https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.parent-container{
width:100vw;
height:100vh;
background-color:black;
display:flex;
justify-content:center;
align-items:center;
}
.child{
width:50%;
background-color:white;
text-align:center;
}
<div class="parent-container">
<div class="child">
<h1>Centered</h1>
</div><!-- child -->
</div><!-- parent-container -->
Flexbox and grid work great for this, the difference being that grid is said to be 2 dimensional whereas flexbox is 1 dimensional. See MDN's Relationship of flexbox to other layout methods. BTW: If you want a sticky footer add min-height: 100vh; to your container.
Both Ron and Jeh's answer are correct. Though I'm wondering why do you have so many container wrappers then if you can just use certain wrappers to display your entire login form, banner and footer.
Here's my template for my custom login forms.
You will noticed that I use calc on height to differentiate the height of banner and footer and then less it to the height of your .section-login container, in which it will automatically adjusted the height no matter what the browser height does. And I declared min-height just to avoid overlaying above to each container wrapper.
Hope this helps.
.login {
background: pink;
margin: 0;
padding: 0;
}
.body-wrapper {
background: white;
width: 100%;
height: 100vh;
}
.hero-wrapper,
.globalfooter {
background: #CCC;
text-align: center;
}
.hero-wrapper {
line-height: 200px; /* just for the text v-alignment only */
height: 200px;
}
.globalfooter {
line-height: 100px; /* just for the text v-alignment only */
height: 100px;
}
.section-login {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #EEE;
min-height: calc(100% - (200px + 100px));
padding: 30px;
box-sizing: border-box;
}
.help-text-wrapper {
font: 300 12px sans-serif;
color: red;
text-align: center;
margin: 15px 0 0;
}
.help-text-wrapper.hidden {
/* Remove comment to enable
display: none; */
}
h1 {
font: 600 24px sans-serif;
text-align: center;
text-transform: uppercase;
margin: 0 0 15px;
}
form {
background: #FFF;
font: 300 12px sans-serif;
text-transform: uppercase;
width: 260px;
padding: 30px;
box-shadow: 0 0 5px 0 rgba(0,0,0,0.50);
box-sizing: border-box;
border-radius: 3px;
}
form > fieldset {
margin: 0 0 15px;
padding: 0;
border: 0;
}
form > fieldset label:first-child {
display: block;
margin-bottom: 15px;
}
form input {
display: block;
width: 100%;
height: 30px;
margin: 5px 0;
padding: 6px;
box-sizing: border-box;
}
form button {
display: block;
background: #888;
color: #FFF;
text-transform: uppercase;
height: 30px;
margin: auto;
padding: 7px 15px;
border: 0;
cursor: pointer;
}
<body class="login page">
<div class="body-wrapper">
<header class="hero-wrapper">
Banner
</header>
<section class="section-login">
<h1>Sign In</h1>
<form action="" method="post">
<fieldset>
<label for="username">
Username
<input type="text" id="username" value="" placeholder="Username" autofocus>
</label>
<label for="password">
Password
<input type="password" id="password" value="" placeholder="Password">
</label>
</fieldset>
<button type="submit">Login / Sign In</button>
</form>
<div class="help-text-wrapper hidden">
Something around here after fallback.
</div>
</section>
<footer class="globalfooter">
Footer
</footer>
</div>
</body>
Just change some class properties which I wrote down:
.login-layout__positioner {
display: flex;
align-items: center;
justify-content: center;
}
.form__group {
background-color: transparent;
}
a {
color: #333;
}
footer a {
color: #fff;
}

I am unable to put a form in the middle of a div with CSS

I am trying to fit the input and button for the search form in the middle of my banner.
But this is what I get:
Here the HTML:
<div class="header-container">
<div class="header">
<h1 class="logo"><strong>Magento Commerce</strong><img src="" alt="Magento Commerce" /></h1>
<div class="quick-access">
<form id="search_mini_form" action="/" method="get">
<div class="form-search">
<label for="search">Search:</label>
<input id="search" type="text" name="q" value="" class="input-text" maxlength="128" />
<button type="submit" title="Recherche" class="button"><span><span>Recherche</span></span></button>
<div id="search_autocomplete" class="search-autocomplete">
</div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', 'Search entire store here...');
searchForm.initAutocomplete('/', 'search_autocomplete');
//]]>
</script>
</div>
</form>
<ul class="links">
<li class="first" ><a href="" title="Mon compte" >Mon compte</a> </li>
<li><a href="" title="My Wishlist" >My Wishlist</a></li>
<li>My Cart</li>
<li>Checkout</li>
<li>Blog </li>
<li class=" last"><a href="" title="Se connecter" >Se connecter</a></li>
</ul>
</div>
</div>
</div>
Here is the CSS:
.header-container {
position:fixed;
background-color: #000;
height:40px;
line-height:40px;
width:100%;
color:#fff;
}
.header {
text-align:right;
height:40px;
line-height:40px;
z-index:10;
}
.header .quick-access {
height: 40px;
line-height: 40px;
}
.header .form-search {
float:right;
height:40px;
width: auto;
line-height:40px;
}
form {
display: inline;
}
I found a way to do it with display: table-cell; and vertical-align: middle; but I don't want to use this technique because I want to support older browsers.
So how come the technique:
height: 40px;
line-height: 40px;
is only working with the ul list menu and not with the input and button?
UPDATE
Here is the jsfiddle link where you can see the problem: example
I will suggest to not using line-height for this... It's not a text block.
Instead... I will use padding-top like this:
.header .form-search {
float: right;
height: 40px;
padding-top: 10px;
box-sizing: border-box;
-moz-box-sizing: border-box; /* FF */
width: auto;
}
Update fiddle: http://jsfiddle.net/gmolop/fELkE/1/
Apply float:left to your <h1> element. This fixes the issue.
FIDDLE
<header>
<h1>some text</h1>
<form>
<input type="text" />
</form>
<button>Button</button>
</header>
css
header
{
height: 40px;
line-height: 40px;
width: 100%;
background: #ccc;
}
input,button,form
{
height: 25px;
display: inline-block;
margin: 0 20px;
}
h1
{
margin:0; padding:0;
display: inline-block;
float:left;
}

css footer doesn't remain at the end of the content

I have a website and I want to put a footer at the end of each page.
The page login has content, but the footer doesn't remain at the end of it.
login
<div class="login">
<form id="loginForm" method="POST" action="<?php echo URL; ?>Login/run">
<li>
<label>
Username:
</label>
<input type="text" name="username"/>
<span class="errorMessage"></span>
</li>
<li>
<label>
Password:
</label>
<input type="text" name="password"/>
<span class="errorMessage"></span>
</li>
<li>
<label>
Type:
</label>
<select name="typeOfUser">
<option value="1">Restaurant</option>
<option value="2">Customer</option>
</select>
</li>
<li>
<label></label>
<input type="submit" value="Login"/>
</li>
</form>
</div>
css
.login{
position: relative;top: 100px;
margin-left: 280px;
}
.login li{
list-style: none;
padding-bottom: 10px;
}
.login label{
color: blue;
display: inline-block;
width: 100px;
}
.login input{
padding: 0.4em;
}
.login select{
padding: 0.4em;
}
footer
#footerContent{
position: relative;
bottom: 0px;
width: 100%;
height: 48px;
background-color: #646467;
}
change your login div css to
.login{
position: relative;
margin-top: 100px;
margin-left: 280px;
}
and footer will come after login div.
Check this jsfiddle
hope it helps
try this
#footerContent{
position: absolute;
bottom: 0;
width: 100%;
height: 48px;
background-color: #646467;
}