CSS is my weak side and now I'm trying to improve it, can you please help me to spot what's the problem is, moreover which css style I'm missing.
<table>
<tr>
<td style=width:"177px; height:92px"><img src="logo.png"></td>
<td rowspan="2"><img src="img2.png"></td>
</tr>
<tr>
<td style=width:"177px; height:100px"><img src="img1.png"></td>
</tr>
</tr>
</table>
UPDATE:
I forgot to mention that I was doing HTML email so solved my issue. Thanks for your help
I think you just need to make the table default CellSpacing and CellPadding 0 (assuming the top picture in your post is the desired result)
<table cellpadding=0 cellspacing=0 >
Although DIV's may be easier
<div>
<div style = width:"177px; height:92px; float:left;">
<img src="logo.png"><br />
<img src="img2.png">
</div>
<div style=width:"177px; height:100px; float:left;">
<img src="img1.png">
</div>
</div>
Then, let's take it 1 step further
<style>
.wrapper
{
background-color:#ccc;
padding:5px;
}
.content
{
width:177px;
height:100px; /*Made them both 100px although one was 92px, this may not be correct*/
float:left;
}
</style>
<div class="wrapper">
<div class="content">
<img src="logo.png"><br />
<img src="img2.png">
</div><!--/content-->
<div class="content">
<img src="img1.png">
</div><!--/content-->
</div><!--/wrapper-->
The property you are looking for may be border-spacing, E.G. border-spacing: 0; (other table specific CSS properties) however you may wish to consult this topic first: Why not use tables for layout in HTML?
Try This one:
css
table {border:1px solid #ccc;
.logo{ width:100px; }.img2{ width:300px }
HTML
<table cellpadding="0" cellspacing="0">
<tr>
<td class="logo">
<img src="logo.png" /><br />
<img src="img1.png">
</td>
<td class="img2"><img src="img2.png"></td>
</tr>
</table>
height is the problem. Decrease the height of logo.png image.
Related
I need to have some text next to an image on an HTML page. So I figured a table was the best way to go...
<table width="500px" >
<tbody>
<tr>
<td align="left">
<p>
<b>Isn't she hot??</b>
</p>
</td>
<td align="right">
<img width="150" height="150" src="http://pixel.nymag.com/imgs/daily/vulture/2015/11/25/25-jennifer-lawrence-directs.w529.h529.jpg" alt="" border="0"/>
</td>
</tr>
</tbody>
Fiddle https://jsfiddle.net/abuMariam/rsnc9vjp/
Problem is what if I want to move that text all the way up or all the way down. I can't because the image width makes both td elements to be wide so I have no way to vertically position the text within its td.
Can I still keep the table but still move the text up and down in its cell?
Yes, just use vertical-align="top" or vertical-align="bottom" on the td. Do you really need to use a table for this though? Tables should seldom be used nowadays, and only for tabular data.
<table width="500px" >
<tbody>
<tr>
<td align="left" style="vertical-align:top;">
<p>
<b>Isn't she hot??</b>
</p>
</td>
<td align="right">
<img width="150" height="150" src="http://pixel.nymag.com/imgs/daily/vulture/2015/11/25/25-jennifer-lawrence-directs.w529.h529.jpg" alt="" border="0"/>
</td>
</tr>
</tbody>
</table>
Here's one way you could do it without using a table, this method causes the divs to act like table cells:
.container {
width:500px;
display:table;
}
.container > div {
width:50%;
display:table-cell;
}
.container > div p {
margin:0;
}
.container .left {
vertical-align:top;
}
.container .right {
text-align:right;
}
<div class="container">
<div class="left">
<p>
<b>Isn't she hot??</b>
</p>
</div>
<div class="right">
<img width="150" height="150" src="http://pixel.nymag.com/imgs/daily/vulture/2015/11/25/25-jennifer-lawrence-directs.w529.h529.jpg" alt="" border="0"/>
</div>
</div>
I want the <img> and Test to be aligned left, but they aren't.
My code:
<center>
<div class="body" id="block">
<span style="width:95%;background-color: rgb(247,247,247);border-radius:10px;display:block;">
<table>
<tr style="height:25px;">
<td style="width:70%;margin-left:10px;font-size:20px;text-align:left;display:block;">
<img style="height:20px;" src="http://i64.tinypic.com/2i9qzj5.png">
Test
</td>
<td style="font-size:12px;">
Another test
</td>
<td style="width:5%;">
</td>
<td style="width:15%;font-size:12px;">
Third test
</td>
</tr>
</table>
</span>
</div>
</center>
I've tried several things, but still does not work.
I don't understand what I'm doing wrong here.
Remove CSS display:block of <td> tag:
<td style="width:70%;margin-left:10px;font-size:20px;text-align:left;display:block;">
New code:
<td style="width:70%;margin-left:10px;font-size:20px;text-align:left;">
By default, <td> in table has CSS: display: table-cell;
True answer:
table { width: 100%; }
It's still messed up, but i don't clean the code.
<center>
<div class="body" id="block">
<div style="width:95%;background-color: rgb(247,247,247);border-radius:10px;">
<table style="width: 100%">
<tr style="height:25px;">
<td style="width:70%;padding-left: 10px;font-size:20px;text-align:left;">
<img style="height:20px;" src="http://i64.tinypic.com/2i9qzj5.png">
Test
</td>
<td style="font-size:12px;">
Another test
</td>
<td style="width:5%;">
</td>
<td style="width:15%;font-size:12px;">
Third test
</td>
</tr>
</table>
</div>
</div>
</center>
Hey this is my first post, but I hope I can help you with my answer. I pulled out the css from your html and also switched to div's, something I would recommend you do.
HTML:
<center>
<div class="body" id="block">
<div class="user item">
<img src="http://i64.tinypic.com/2i9qzj5.png">
Test
</div>
<div class="title item">
Another Test
</div>
<div class="third item">
Third test
</div>
</div>
</center>
CSS:
.body {
width:100%;
height:25px;
background-color: rgb(247,247,247);
border-radius:10px;
display:block;
}
.item {
width:20%;
display:inline-block;
}
.user {
float:left;
font-size:20px;
}
.user img {
height:20px;
}
.title {
font-size:12px;
}
.third {
}
.td4 {
font-size:12px;
}
JSFiddle
I am coding in html-email. There is a <td> with inline CSS code. What I have to do for attach an anchor tag on whole <td>. Please tell me how can I do it. I have tried many options but these are not valid.
<td valign="top" width="204" class="leftColumnContent" mc:edit="left_column_content" align="center" bgcolor="#dee0e2" style="border-left:6px solid #FFF; border-top:5px solid #FFF;"">
<div align="center" style=" margin-top:10px;">
<img src="" width="119" height="199" style="max-width:180px;" mc:label="image" />
</div>
<p style=" margin-left:20px; width:80%; font-family:Arial, Helvetica, sans-serif; font-size:14px;"> <strong>Text here </strong><br />
<br />
text here</p>
<div style="width:80%; margin-top:10px; margin-left:20px; margin-bottom:15px;">
<div align="left" style="float:left;"><strong> read more</strong></div>
<div align="right">
<img align="none" height="20" id="headerImage2" mc:allowdesigner="" mc:allowtext="" mc:label="header_image" src=".." style="max-width: 55px; width: 55px; height: 23px;" width="55" /></div>
</div>
</td>
You cannot have <a ...><td>...</td></a>, by HTML rules. You can nest them the other way around, <td><a ...>...</a></td>. If you need to make the entire cell clickable, then you need to style the a element so that it occupies the entire cell. The way to do that depends on context, but if the td element has fixed dimensions, then set the following on the a element inside it:
display: block; height: 100%;
you can use the onclick property at the place of Anchor Tag in your table (code).
the Table example is as follows
<table>
<tr>
<td onclick="javascript:alert('your HTML');">HTML Code is here</td>
</tr>
</table>
at the place of alert("") you can use window.location("")
for send the page redirection on another page.
I got a simple question regarding the CSS background image.
My intention was using image to display round corner on table edges (without using border-radius property).
<style type="text/css">
.top
{
background-repeat:repeat;
vertical-align:top;
}
.left
{
text-align:left;
}
.middle
{
}
.right
{
text-align:right;
}
.bottomLeft
{
vertical-align:bottom;
}
.bottom
{
background-repeat:repeat;
vertical-align:bottom;
}
.bottomRight
{
vertical-align:bottom;
}
</style>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="topLeft">
<img height="16px" src="Images/greenTL.gif" style="vertical-align:bottom" />
</td>
<td class="top">
<img height="4px" width="100%" src="Images/greenT.gif" style="vertical-align:8px" />
</td>
<td class="topRight">
<img height="16px" src="Images/greenTR.gif" style="vertical-align:bottom" />
</td>
</tr>
<tr>
<td class="left">
<img height="100%" src="Images/greenL.gif"/>
</td>
<td class="middle">
</td>
<td class="right">
<img height="100%" src="Images/greenR.gif"/>
</td>
</tr>
<tr>
<td class="bottomLeft">
<img height="16px" src="Images/greenBL.gif" style="vertical-align:top" />
</td>
<td class="bottom" >
<img height="4px" width="100%" src="Images/greenB.gif" />
</td>
<td class="bottomRight">
<img height="16px" width="16px" src="Images/greenBR.gif" style="vertical-align:top"/>
</td>
</tr>
</table>
The HTML & CSS above work perfectly fine in IE from Browser Mode 7 to 9, but it became distorted when changed Document Mode to IE 7 Standard.
It seem like having a gap between left and right vertical.
How can I solve the issue?
Before having CSS3 border-radius, what is the best approach to implement round corner in web page?
thank you in advanced.
I would use something like http://css3pie.com/ which enables some CSS3 features on < IE9
versions. Personally, i'm one of those persons who think that web page shouldn't look 100% the same in all browsers e.g. Chrome/Firefox/Safari should get rounded corners and < IE9 should not.
Don't use tables for layout. For rounded corners in browser that don't support native border-radius, you can use graphics corners as background of absolutely-positioned empty elements.
I read that each column of a table can be styled using <colgroup> and <col>. I tried the following, but the style speficication is not seeming to work. How can I fix it?
When I do this with width property, it works. Is there anything wrong with text-align property?
<html><body><table>
<colgroup>
<col style="text-align:right" />
<col style="text-align:center" />
<col style="text-align:left" />
</colgroup>
<tr>
<td>aaaaaaaaaaa</td>
<td>bbbbbbbbbbb</td>
<td>ccccccccccc</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
</table></body></html>
The result is that each colum is left aligned by default, ignoring the specification made in colgroup.
I am using Chrome 17.
While support for colgroup and col seems to be spotty, I don't think one should throw out the baby with the bathwater. I think tables have their place, to display tabular data. Using divs to display tabular data borders on table-phobia in my opinion.
<html><body>
<style>
.left {text-align:left;}
.center {text-align:center;}
.right {text-align:right;}
</style>
<table>
<tr>
<td class="left">aaaaaaaaaaa</td>
<td class="center">bbbbbbbbbbb</td>
<td class="right">ccccccccccc</td>
</tr>
<tr>
<td class="left">aaa</td>
<td class="center">bbb</td>
<td class="right">ccc</td>
</tr>
</table>
</body></html>
If not in need of tables, here´s how I´d do it tableless, just in case:
HTML:
<div id="container">
<div class="left">left aligned text</div>
<div class="center">center aligned text</div>
<div class="right">right aligned text</div>
</div>
CSS:
.container {}
.left {
width:100px;
float:left;
text-align:left;
}
.center {
width:100px;
float:left;
text-align:center;
}
.right {
width:100px;
float:left;
text-align:right;
}
(and you could just unify all the common styles with commas and just separate the text-alignment)
Don't use tables, use divs. Obviously the following should be seperated out into classes and such, but it works.
<html><body>
<div style="display: table">
<div style="display: table-row">
<div style="display: table-cell;">aaaaaaaaaaa</div>
<div style="display: table-cell;">bbbbbbbbbbb</div>
<div style="display: table-cell;">ccccccccccc</div>
</div>
<div style="display: table-row">
<div style="display: table-cell; text-align:right;">aaa</div>
<div style="display: table-cell; text-align:center;">bbb</div>
<div style="display: table-cell; text-align:left;">ccc</div>
</div>
</div>
</body></html>