I am having trouble getting a border on a table. Here is the html for the table it shows having a border in Dreamweaver but not on the live webpage. I also have other tables on the page and do not want them to have the borders just this one.
<table style="width: 100%;" border="1" bordercolor="#000000">
<tr>
<td colspan="2" align="center" valign="middle">Please comeplete form</td>
</tr>
<tr>
<td width="50%">Event Name:</td>
<td>
<input type="text" name="name" id="name"></td>
</tr>
<tr>
<td>Date (YYYY-MM-DD):</td>
<td>
<textarea name="date" id="date"></textarea></td>
</tr>
<tr>
<td>Link to page:</td>
<td>
<input type="text" name="link" id="link"></td>
</tr>
<tr>
<td>Status:</td>
<td>
<input type="text" name="status" id="status"></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><input type="submit" name="submit" id="submit" value="Submit"></td>
</tr>
</table>
You can add CSS to bring it up to standard
Something like:
table.mytable{
border: 1px solid #000000;
}
and then add a class="mytable" attribute to your table
You can initially style it like:
table,td,th {
border-collapse:collapse;
border: 1px solid #000000;
}
And in this way further you can add this as a class.
Related
So I have an order form which works well but when I test it on smaller screens a part of it goes way off to the side, the rest is how it should be this one part is not for some reason.
This is the html code of the part that goes wrong:
<div class="contact" align="center">
<p>Please tell us who you are</p>
<table border="0" cellpadding="0" width="550" id="table1">
<tr>
<td width="340" align="right">Name</font></td>
<td width="10"> </td>
<td width="200"><input type="text" name="name" id="name" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right">Email</font>
(Your confirmation will be sent here): </td>
<td width="10"> </td>
<td width="200"><input type="text" name="email" id="email" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right">Phone number:</td>
<td width="10"> </td>
<td width="200"><input type="text" name="number" id="number" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right">Address:</td>
<td width="10"> </td>
<td width="200"><input type="text" name="address" id="address" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right">Town:</td>
<td width="10"> </td>
<td width="200"><input type="text" name="town" id="town" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right">Postcode:</td>
<td width="10"> </td>
<td width="200"><input type="text" name="postcode" id="postcode" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right">County:</td>
<td width="10"> </td>
<td width="200"><input type="text" name="county" id="county" required size="30" tabindex="1"></td>
</tr>
<tr>
<td width="340" align="right"> </td>
<td width="10"> </td>
<td width="200"> </td>
</tr>
</table>
</div>
and not sure if it will help but this is the style for the border:
form {
border-top-style: dotted;
border-right-style: dotted;
border-bottom-style: dotted;
border-left-style: dotted;
}
For dealing with different screen sizes I added:
<meta name="viewport" content="width=device-width, initial-scale=1">
I have attached an image of what is happening to show what I mean:
I'm just not sure why this one bit is doing it and the rest of the form is fine? Any help would be much appreciated
Add width: 100%; to the table element. Then adjust the width values you have given to each of the td elements. (I’d advise against a forced width for them, but it’s fine.)
It looks like this now—
I have seen unnecessary code
like <td>title</td><td width="10"> </td> Can be replace with <td style="padding right: 10px">title</td>
blank last row <tr><td> </td></tr> Can be replace with table CSS margin-bottom: 20px;
By the way
you need to remove <td width="100"> to <td>
table{
width: 100%;
margin-bottom: 20px;
}
tr>td:first-child{
width:auto;/*340*/
padding-right: 10px;
}
tr>td:last-child{
width:auto;/*2pp*/
}
With my JSFiddle Now you can resize to... ~ 331px width (Can be resize less. If cut down size Input's attribute)
I am writing my final project at PHP and JS. I need help with the html and CSS styling.
This is my sign form, I want help in 2 things.
I want to do that the whole row (tr) that include th while be with border, now I know to do it only that every th have border.
I want to divide the table to sections and to style every section in other CSS code.
How can I do it?
This my HTML code:
<body>
<form>
<table id="t">
<tr>
<th>Basic info</th>
<th>Contact info</th>
<th>About me</th>
</tr>
<tr>
<td><input placeholder="First name"></td>
<td><input placeholder="Phone"></td>
<td rowspan="3"><textarea rows="8" placeholder="About me"></textarea></td>
</tr>
<tr>
<td><input placeholder="Last name"></td>
<td><input placeholder="Area"></td>
</tr>
<tr>
<td><input placeholder="Degree"></td>
<td><input placeholder="Email"></td>
</tr>
<tr><th colspan="2">Social networks</th></tr>
<tr>
<td><input row placeholder="Facebook link"></td>
<td><input row placeholder="Website link"></td>
</tr>
<tr>
<td><input row placeholder="Twitter link"></td>
<td><input row placeholder="Medium link"></td>
</tr>
<tr>
<td><input row placeholder="Instagram link"></td>
<td><input row placeholder="Google link"></td>
</tr>
<tr><td colspan="2"><button type="submit">שלח</button></td></tr>
</table>
</form>
</body>
This is my CSS:
table{
margin: 16px;
text-align: center;
}
td{
padding: 10px;
justify-content: space-between;
}
#t textarea{
width: 100%;
height: 100%;
}
tr>th{
margin-top: 10px;
border: 1px solid red;
}
For (1), tr's can only have borders when the table is border-collapse:collapse.
For (2), you can put rows in <thead>, <tbody>, <tfoot> sections and style those separately.
Maybe you can have multiple <tbody> sections and use nth-of-type to select them but I don't know.
Differences in the below
addition of thead, tbody, tfoot in the html
style tbody as an example
border-collapse:collapse on the table style
tr style on the first tr
table {
margin: 16px;
text-align: center;
border-collapse: collapse;
}
td {
padding: 10px;
justify-content: space-between;
}
#t textarea {
width: 100%;
height: 100%;
}
tbody {
font-style: italic;
}
<form>
<table id="t">
<thead>
<tr style="border:solid 1px">
<th>Basic info</th>
<th>Contact info</th>
<th>About me</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input placeholder="First name">
</td>
<td>
<input placeholder="Phone">
</td>
<td rowspan="3">
<textarea rows="8" placeholder="About me"></textarea>
</td>
</tr>
<tr>
<td>
<input placeholder="Last name">
</td>
<td>
<input placeholder="Area">
</td>
</tr>
<tr>
<td>
<input placeholder="Degree">
</td>
<td>
<input placeholder="Email">
</td>
</tr>
<tr>
<th colspan="2">Social networks</th>
</tr>
<tr>
<td>
<input row placeholder="Facebook link">
</td>
<td>
<input row placeholder="Website link">
</td>
</tr>
<tr>
<td>
<input row placeholder="Twitter link">
</td>
<td>
<input row placeholder="Medium link">
</td>
</tr>
<tr>
<td>
<input row placeholder="Instagram link">
</td>
<td>
<input row placeholder="Google link">
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<button type="submit">שלח</button>
</td>
</tr>
</tfoot>
</table>
</form>
I am very new to Bootstrap css, can any one help me to design table header like this, column is seperated by pipe like css
Below is css .
<style>
.table-bordered tbody tr td {
border: none !important;
}
.table-bordered tbody tr td input.form-control[type=text] {
border-radius: 0px !important;
}
#input_container {
position: relative;
direction: rtl;
}
#input_img {
position: absolute;
bottom: 4px;
right: 5px;
width: 24px;
height: 24px;
}
Here i have used "table table-bordered" class for table and using above css i have removed td border lines
<div class="container">
<table class="table table-bordered">
<thead>
<tr>
<th>Product Name</th>
<th>Color/Size</th>
<th>Qty. Needed</th>
<th>Need By Date</th>
<th>Special Instructions</th>
<th>Art Files</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="form-control" id="Text1" type="text" /></td>
<td>
<div id="input_container">
<input class="form-control" type="text" id="input" value="">
<img src="~/Images/calendarImg.png" id="input_img">
</div>
</td>
<td><input class="form-control" id="Text1" type="text" /></td>
<td>
<input class="form-control" type="text" />
</td>
<td><input class="form-control" id="Text1" type="text" /></td>
<td><input class="form-control" id="Text1" type="text" /></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="6"><a>Add Rows</a></td>
</tr>
</tfoot>
</table>
I have created a demo for you. Take help and modify as per your requirement.
<table frame="box" rules="none" cellpadding="2" cellspasing="5"> <tr style="background-color:yellow; ">
<td colspan="4">
<table style="width:100%">
<tr>
<td style="width:25%;border-right: thin solid #000;">First</td>
<td style="width:25%;text-align:center; border-right: 1px solid #000;">Second</td>
<td style="width:25%;text-align:center;border-right: 1px solid #000;">Third</td>
<td style="width:25%;text-align:center;">Fourth</td>
</tr>
</table>
</td> </tr> <tr>
<tr>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
</tr>
<tr>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
</tr> </tr> </table>
click here to see it in fiddle
I have two different tables and on the second table I want to apply the border="border" atttribute as CSS. How can accomplish this correctly?
<table>
<!-- Text widgets for the customer's name and address -->
<tr>
<td>Buyer's Name:</td>
<td>
<input type="text" name="name" size="30" />
</td>
</tr>
<tr>
<td>Street Address:</td>
<td>
<input type="text" name="street" size="30" />
</td>
</tr>
<tr>
<td>City, State, Zip:</td>
<td>
<input type="text" name="city" size="30" />
</td>
</tr>
</table>
<table class="tableProduct">
<!-- First, the column headings -->
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<!-- Now, the table data entries -->
<tr>
<td>Unpopped Popcorn (1 lb.)</td>
<td>$3.00</td>
<td class="tdcenter">
<input type="text" name="unpop" size="3" />
</td>
</tr>
<tr>
<td>Caramel Popcorn (2 lb. canister)</td>
<td>$3.50</td>
<td class="tdcenter">
<input type="text" name="caramel" size="3" />
</td>
</tr>
<tr>
<td>Caramel Nut Popcorn (2 lb. canister)</td>
<td>$4.50</td>
<td class="tdcenter">
<input type="text" name="caramelnut" size="3" />
</td>
</tr>
</table>
I tried creating the classs tableProduct with the following:
.tableProduct {
border: 1px solid black;
border-collapse: collapse;
}
But it just creates a border around the table. I want it to create a border within each cell.
Here we go ... you weren't that far from it
.tableProduct {
border-collapse: collapse;
}
.tableProduct th, /* this line is for the headers */
.tableProduct td {
border: 1px solid black;
}
<table>
<!-- Text widgets for the customer's name and address -->
<tr>
<td>Buyer's Name:</td>
<td>
<input type="text" name="name" size="30" />
</td>
</tr>
<tr>
<td>Street Address:</td>
<td>
<input type="text" name="street" size="30" />
</td>
</tr>
<tr>
<td>City, State, Zip:</td>
<td>
<input type="text" name="city" size="30" />
</td>
</tr>
</table>
<table class="tableProduct">
<!-- First, the column headings -->
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<!-- Now, the table data entries -->
<tr>
<td>Unpopped Popcorn (1 lb.)</td>
<td>$3.00</td>
<td class="tdcenter">
<input type="text" name="unpop" size="3" />
</td>
</tr>
<tr>
<td>Caramel Popcorn (2 lb. canister)</td>
<td>$3.50</td>
<td class="tdcenter">
<input type="text" name="caramel" size="3" />
</td>
</tr>
<tr>
<td>Caramel Nut Popcorn (2 lb. canister)</td>
<td>$4.50</td>
<td class="tdcenter">
<input type="text" name="caramelnut" size="3" />
</td>
</tr>
</table>
You need to apply the styling to the th and td elements as well.
table, th, td {
border: 1px solid black;
}
You can read up on table styling more here.
table.tableProduct td {
border: 1px black solid;
border-collapse: collapse;
}
That will put a border around all of your table datas individually.
For good measure, you might want to add border-collapse in there. That way you're looking at one solid border, instead of two competing border lines - one from the table and one from the table data.
Edit: With css Combinators! By putting a space between table.tableProduct and td, we're saying, please apply these CSS rules to all td elements that a descendants of a table element with the class tableProduct.
I am trying to create a table in which the border will appear like a login box.
<table border="1">
<tr>
<td>Username: </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Log In" /></td>
</tr>
</table>
What happens is that even the table cells have border and the border sucks. I want to remove cell border. The border should only be wrapping around the table. I am totally new to this.
Thanks in advance.
Use CSS
<style type="text/css">
.loginbox {
border-collapse: collapse;
border-width: 1px;
border-style: solid
}
</style>
<table class="loginbox">
<tr>
<td>Username: </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Log In" /></td>
</tr>
</table>
FYI: I added colspan="2" to your last <td> in order to make the border go all the way around.
If you use the following css,
table {
border: thin solid black;
}
that will give you a border around the table only, you can see a jsfiddle for it at http://jsfiddle.net/2CdwW/
Use CSS to put the border on the table instead:
<table style="border: 1px solid black">
<tr>
<td>Username: </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Log In" /></td>
</tr>
</table>