Jump to content
Stef's Coding Community
Sign in to follow this  
Ant

Difference between 2 types of style

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...