Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i have tried all other way search on stackoverflow etc but couldn't found my answer
my div id is loginbox.
<div id="loginbox">
<form action="post">
<table>
<tr>
<td><label>Username:</label></td>
<td><input id="username" type="text" placeholder="username"/></td>
</tr>
<tr>
<td><label>Password:</label></td>
<td><input id="password" type="password" placeholder="password"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
</div>
I can't see your CSS, but considering just what's in your question, this should work:
#loginbox form table {
margin: 0 auto;
}
Demo: http://jsfiddle.net/TmY46/
And this isn't related to HTML5. It's purely CSS.
Depending on what exactly you want to have:
#loginbox table { margin:auto; }
or
#loginbox * { text-align:center; }
or
#loginbox table * { margin:auto; }
or any combination!?
First or all, you shouldnt use a table for that.
Anyway, something like that :
td{text-align:center;}
form input{display:block;margin:auto;}
If you really want to code in html5, i encourage you to use a different structure,
like :
<form>
<p><label>Username :</label><input type=text /><span style="clear:both"></span></p>
<p><label>Password :</label><input type=password /><span style="clear:both"></span></p>
<input type=submit vale="login" />
</form>
And in css :
form {margin:auto;}
form p{display:block;margin:3px 0;}
form input[type=text], form input[type=password]{float:left;width:150px;}
This is how i would do, it's cleaner and much flexible
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am currently trying to implement a simple feedback form for my site. However, the boxes are very small and don't really match the theme of my site at all. I have tried increasing text size and margin with CSS, but I can't seem to make them larger.
Any help would be greatly appreciated!
<form action="form" method="POST" class="formone">
<input type='text' name='name' placeholder='John Doe' /><br/>
<input type='text' name='message' placeholder='Your message'/><br/>
<input type='submit' value='submit' />
</form>
You can modify it by giving them a class and then defining the font-size for those classes.
For example:
.one{
font-size: 20px;
}
.two {
font-size: 40px;
}
<form action="form" method="POST" class="formone">
<input class="one" type='text' name='name' placeholder='John Doe' /><br/>
<input class="two" type='text' name='message' placeholder='Your message'/><br/>
<input class="three" type='submit' value='submit' />
</form>
I hope it helps.
Edit:
You can also try using inline style like this if it's not working due to some other style statement overriding this:
<form action="form" method="POST" class="formone">
<input style="font-size:20px !important;" type='text' name='name' placeholder='John Doe' /><br/>
<input style="font-size:30px !important;" type='text' name='message' placeholder='Your message'/><br/>
<input type='submit' value='submit' />
</form>
I would recommend to use textarea and using text area you can set height and width of it.
<textarea name="message" rows="10" cols="30">
The cat was playing in the garden.
</textarea>
In text area rows and cols are set as default textarea size and it is expandable.
As you have used <input type='text'/> It does not holds property of height and width so you cannot change it with css.
For better understanding refer these two links : https://www.w3schools.com/tags/att_input_width.asp
https://www.w3schools.com/html/html_form_elements.asp
Hope it helps
Thanks
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I'm looking for a way to make some CSS only apply if an input outside the style sheet has a certain value.
In the example below I only want to run the CSS if the input value below is "4625585".
It is from a form where the submit button sends the input value (among other things).
Is that possible at all when I only have access to CSS and not the HTML code of the form.
Kindly, Rasmus
-
Here is the CSS
<style type="text/css">
.wForm {
font-family: sans-serif;
}
</style>
<input value="4625585">
-
Here is the HTML:
<form>
<div id="tfa_6" class="wForm">
<input type="text" placeholder="Name">
</div>
<div class="actions">
<input type="submit" value="Submit">
</div>
<input value="4626442">
</form>
You can only apply CSS to a sibling that follows the element that's validated. Therefore I moved the input element with value 4625585 to the top in the form.
If you don't have access to the HTML, you will need javascript.
input[value="4625585"] ~ .wForm {
background: red;
}
<form>
<input value="4625585">
<div id="tfa_6" class="wForm">
<input type="text" placeholder="Name">
</div>
<div class="actions">
<input type="submit" value="Submit">
</div>
</form>
The issue was commented on and answered in a deleted threat. This short answer is "no, it can't be done".
This question already has answers here:
Align form elements in CSS
(3 answers)
Closed 6 years ago.
I'm new to HTML, this being my first project. I'm trying to design a simple calculator, identical to this image.
The problem I'm having is I can't find a simple way to put spacing between the labels i.e "term, interest rate" and the input boxes meaning the layout looks poor. The easiest I've found is adding loads of  's but that seems ludicrous.
For example in the code below how can I get spacing between the "Term" and the input box?
<form>
<label>
Term <input name ="term" type ="text"/>
</label>
</form>
.table tr td{
text-align:right;
}
/*this sets padding space */
.table tr td{
padding-top:10px;
}
<form>
<table class="table">
<tr>
<td>
<label> Term </label>
</td>
<td><input name ="term" type ="text"/></td>
</tr>
<tr>
<td>
<label> Rate Blah Blah </label>
</td>
<td><input name ="blahblah" type ="text"/></td>
</tr>
</table>
</form>
you can use it like this
This question already has answers here:
Give border title in div
(4 answers)
Closed 7 years ago.
I guess its really simple, but I cant find it as I'm don't know how it is called.
I want to make a border with a title, something like this:
----TITLE_HERE----------------------------------
You can use the <fieldset> and <legend> tags to achieve this, as demonstrated in the code below pulled from this answer:
<div id="form" style="width:350px;">
<fieldset>
<legend style="color:blue;font-weight:bold;">General Information</legend>
<table>
<tr>
<td><span style="text-decoration:underline">C</span>hange Password To:</td>
<td><input type="text"/></td>
</tr>
<tr>
<td><span style="text-decoration:underline">C</span>onfirm Password:</td>
<td><input type="text"/></td>
</tr>
</table>
</fieldset>
</div>
I think you're going for something like this :
fieldset {
border : none;
border-top : 1px solid #000;
}
<fieldset>
<legend>Title</legend>
Here is some demo content
</fieldset>
See also this Fiddle.
I need to align the labels on the left hand side properly, so that the textbox and text area at the same place..I have added a class to set the width but that does not work properly.
FIDDLE
Code:
<div id="feedbackdialogbox">
<div>
<h3>Feedback</h3>
</div>
<ul>
<li>
<label for="feedback_nm" class="feedback-label-len">(Optional) tell us who you are</label>
<input type="text" id="feedback_name">
<br>
</li>
<li>
<label for="feedback_msg" class="feedback-label-len">How can we do better?</label>
<textarea rows="5" id="feedback_msg" placeholder="Go ahead, type your feedback her..."></textarea>
<br>
</li>
<li>
<div id="radio_button_list_title_wrapper">
<div id="radio_button_list_title" class="feedback-label-len">How likely are you to recommend Prices Paid to a colleague (1 means not likely, 5 means very likely)?</div>
</div>
<br>
</li>
</ul>
<button id="feedback_submit">Send</button>
</div>
css
.feedback-label-len {
width:600px;
}
I think if I were in your place, I'd just add two </br> below the labels.
They are:
On the left hand side
They are left-aligned as well.
This obviously shall give you the same effect as
label {display:block;}
Adding display: block to the labels would be a fine solution for a simple form. If you're set on putting them side by side...
label {display: block; float: left}
li {overflow: hidden
.feedback-label-len {
display: block;
}
JSFIDDLE
I would use a table.
JSFIDDLE
<form method="post" action="feedback.php">
<table id="feedbackTable">
<tr>
<th><label for="txtName">(Optional) tell us who you are</label></th>
<td><input type="text" id="txtName" style="color:#000000" title="Enter your name" name="txtName" placeholder="Enter Your Name" /></td>
</tr>
<tr>
<th class="message"><label for="">How can we do better?</label></th>
<td><textarea title="Enter your message" name="txtMessage" rows="5" id="txtMessage" placeholder="Go ahead, type your feedback her..."></textarea></td>
</tr>
<tr>
<th><label for="txtEmail">How likely are you to recommend Prices Paid to a colleague (1 means not likely, 5 means very likely)?</label></th>
<td><input type="text" id="txtEmail" title="Enter your email address" name="txtEmail" value=""/></td>
</tr>
<tr>
<th><label title="Send"></label></th>
<td><input type="submit" style="color:#000000" value="Send" /></td>
</tr>
</table>
</form>
One approach you can try using is using tables in order to format the data. Using the table, tr (table row), and td (table data) html tags we can format the data in so that they are spaced correctly without using CSS!!!
<DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="feedbackdialogbox">
<div>
<h3>Feedback</h3>
</div>
<table>
<ul>
<tr>
<td>
<li><label for="feedback_nm" class="feedback-label-len">(Optional) tell us who you are</label></li></td>
<td><input type="text" id="feedback_name"></td>
</tr>
<tr>
<td><li><label for="feedback_msg" class="feedback-label-len">How can we do better?</label></li></td>
<td><textarea rows="5" id="feedback_msg" placeholder="Go ahead, type your feedback her..."></textarea></td>
</li></tr>
<li>
<div id="radio_button_list_title_wrapper">
<div id="radio_button_list_title" class="feedback-label-len">How likely are you to recommend Prices Paid to a colleague (1 means not likely, 5 means very likely)?</div>
</div>
<br>
</li>
</ul>
</table>
<button id="feedback_submit">Send</button>
</div>
</body>
</html>
Just so you know this method may upset html purists. The tag was designed to actually display table data and using it for other purposes such as formatting is sometimes considered improper by old school web coders. However it I have not been able to find an actual problem caused by formatting data like this and doing so is the easiest way for you to make pages such as the one you are asking about.
I hope this answered your question, if you need me to expand on this just ask but when I ran the code above it gave me something much like you described.