1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Again: any reason to use CSS instead of HTML??

Discussion in 'HTML & Website Design' started by tayiper, Jul 5, 2007.

  1. #1
    I will ask this question once again: is there any reason to use CSS-styling instead of HTML-attributes (in cases such as border around a graphic; see below), or it doesn't really matter, and one should probably only look for a size of the code (i.e. which method needs more lines/chars)??!


    The HTML-style example code:

    <a href="http://www.mypagerank.net"><img border="0" src="http://www.mypagerank.net/smerankcheck.php?site=tadejpersic.50webs.com&amp;s=style4" alt="Google PageRank by Scriptme" /></a>
    Code (markup):

    The CSS-style example code:

    <a href="http://www.mypagerank.net"><img style="border: 0;" src="http://www.mypagerank.net/smerankcheck.php?site=tadejpersic.50webs.com&amp;s=style4" alt="Google PageRank by Scriptme" /></a>
    Code (markup):
    (note the style="border: 0; CSS-styling applied to IMG element instead of border="0" HTML-attribute in the two examples above; I edited the post afterwards and moved them to the beginning of the code so that it's visible without horizontal scrolling)


    I remembered to ask this question again when I was editing the Mypagerank badge's code yesterday!! While originally I asked this in Any reason to rather use CSS and not HTML... thread, but back then folks didn't understand my question correctly.


    tayiper
     
    tayiper, Jul 5, 2007 IP
  2. tony84

    tony84 Well-Known Member

    Messages:
    1,864
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    140
    #2
    border doesnt need to be in the tag on css, other than thar, nope i dont think so
     
    tony84, Jul 5, 2007 IP
  3. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you're using CSS elsewhere, then the best thing would probably be to use CSS for consistency's sake. Otherwise, meh.
     
    rgchris, Jul 5, 2007 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    BOTH are bad practice. I would even go so far as to use the /b-tard term "/FAIL/ at intarweb" on that one.

    Why both? Because you have your presentation in your HTML. You should have that in an EXTERNAL style sheet - and since 99.9% of the time you don't want images to have a border anyways, you could declare it ONCE

    img {
    border:none;
    }

    and hit all your images in one call.

    Inlining ANY presentation these days usually just makes bigger bloated code. When we say just put it in CSS, we do NOT mean inline it on each and every element.
     
    deathshadow, Jul 5, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You don't use CSS instead of HTML, you use it in conjunction with HTML.

    There are four layers to the front-end of the Web. Structure (HTML), content (what you read and see on the page), presentation (the layout and typographical presentation, or "how" you see what you read on the page), and behavior (client-side scripting and "events").

    HTML is a structural document markup language, and should be used to define the content of your Web pages and the site as a whole. The content fits within the framework created by the HTML document, while CSS controls how that structure and content is presented to the user. Behavior can be added by scripting (and sometimes CSS can do this as well, such as with dropdown menus and image rollovers).

    Be sure to keep the four separated in your pages as much as possible. With structure and content, it will be impossible to do so, so make the content fit the structure as much as possible (you can technically remove the content from the structure by using a database, but that's beyond the scope of this post) when coding your pages, then use a single external file to serve your stylesheet (CSS document) to the browser, and as few external script files as possible (I prefer a single library.js file myself) when using scripting in your pages.

    If you use inline CSS or scripting (such as JavaScript or vbScript) in your HTML, you've got problems (from a maintainence point of view) since it will be much harder to make site-wide changes in the future.

    Also make sure you use the bare minimum of HTML code possible for defining your document's structure. Don't wrap DIV tags around everything; instead, let the element you're using define the structure.
     
    Dan Schulz, Jul 5, 2007 IP
  6. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #6
    You know that I was actually already thinking about this; if you are interested please see How many external style sheets is too many? (in particular see this post of mine) thread ...


    tayiper
     
    tayiper, Jul 6, 2007 IP