Jump to content

Recommended Posts

Posted

Whats the difference between these two items?

 

<img width="120" style="padding:0px 0px 15px 0px;

 

and

 

<img width="120" padding:0px 0px 15px 0px;

 

When I see this width="120" I'm not sure how to add inline css to it. For instance i wanted to add padding to the image but wasn't sure if doing it like this was valid: padding:0px 0px 15px 0px;

 

 

Here's another example: <table style="width: 800px;" border="0">

 

Can I do this if I want to define font size: <table style="width: 800px;" border="0" font-size:20px;>

 

Thanks,

A.

Posted (edited)

Acceptable:

<img width="120" style="padding:0px 0px 15px 0px;" src="url">

 

Preferred:

<img style="width: 120px; padding:0px 0px 15px 0px;" src="url">

 

 

Incorrect:

<img width="120" padding:0px 0px 15px 0px; src="url">

You can't add padding inline without the using style="" as shown above. 'width' and 'border' are acceptable but preferred to be used within the style="" or external stylesheet.

 

 

Acceptable:

<table style="width: 800px;" border="0">

 

Preferred:

<table style="width: 800px; border:0;">

 

 

Incorrect:

<table style="width: 800px;" border="0" font-size:20px;>

Font size should be contained within the style="".

 

Corrected:

<table style="width: 800px; border:0; font-size:20px;">

Edited by Eddie
Posted (edited)

To add to my last post, here's the best way to do this using external css stylesheet:

 

HTML:

<img class="myimage" src="url">

 

CSS:

.myimage { width: 120px; padding:0px 0px 15px 0px; }

 

 

HTML:

<table class="mytable">

 

CSS:

.mytable { width: 800px; border:0; font-size:20px; }

Edited by Eddie
Posted

Thanks Eddie. You cleared it up for me.

 

I would use external style sheets but these are random needs that I just wanted to adjust using inline.

 

Thanks again,

A.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...