Announcement

Collapse
No announcement yet.

Question about HTML

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about HTML

    Greetings. In my pursuit to learn HTML, I have a question about adding attributes to block level elements. Why is it that when you add style attributes to elements like:

    <head style="background-color: rgb(0,255,255); font-family: cursive, fantasy sans-serif">

    you include the font and bg color attribute within the style="" tag, but when you use...um...like:

    <table height="40%" width="90%" border="5" style="font-size: 50%">

    the height and width info is not to be included in the style tag? I mean, it's going to be hard to remember when to put what in the style tag, and what to leave outside and indicate seperately within the opening <table> tag. Can someone explain how I can figure out exactly what a style is, and when I should indicate an attribute using the style="" thingy?

  • #2
    http://www.w3schools.com/html/

    That place is pretty useful for learning web stuff. Not that I'm being specifically helpful, I'm sure someone will answer your question soon.

    Comment


    • #3
      You can style <table>.

      For example:
      Code:
      <table style="height:50px; width:50px; border:5px solid black; background-color:blue; font-size:8px;">
      <td>Yay.</td>
      </table>
      You can pretty much style anything (although it's better to do it in a seperate style sheet).
      Code:
      ## style.css ##
      table {
       height : 50px;
       width : 50px;
       border : 5px solid black;
       background-color : blue;
       font-size : 8px;
      }
      
      ## file.html ##
      <link rel="stylesheet" href="style.css" type="text/css">
      <table>
      <td>Yay.</td>
      </table>
      A style tells the browser how to display an element. It's that simple. If for some crazy reason I want <b> to underline instead of bold things, I can specify:
      Code:
      b {
       font-weight : lighter;
       text-decoration : underline;
      }
      But what if I want some of the <b> tags to bold? I can do this:
      Code:
      b.bold {
       font-weight : bold;
       text-decoration : none;
      }
      Now the HTML:
      Code:
      ## This would underline the text ##
      <b>This text would be underlined.</b>
      
      ## This would bold the text ##
      <b class="bold">Hooray for bold text.</b>
      Like Nockm said, check here and here.

      Also, a lot of tags and some attributes are deprecated in XHTML Strict. For example, in XHTML Strict, you can't use the "border" attribute in <img>, you have to specify the border in a stylesheet.
      Code:
      ** In HTML **
      <img src="picture.jpg" border="1">
      
      ** In XHTML Strict **
      ## style.css ##
      img {
       border : 1px solid black;
      }
      
      ## file.html ##
      <link rel="stylesheet" href="style.css" text="text/css">
      <img src="picture.jpg" />
      It may seem like more work, but when you have a lot of HTML files linking to one stylesheet, and you want to change the visited link color in all of those HTML files, all you have to do is change one CSS file. Wonderful stuff.

      Check my site for more examples. I have a simple CSS file with simple and clean HTML. The CSS file is here, and my site is here (view source).

      Hope I didn't confuse you?
      Last edited by Saturn V; 02-22-2005, 08:15 AM.
      Ferengi Rule of Acquisition #98: Every man has his price.

      Comment


      • #4
        Originally posted by Saturn V
        Hope I didn't confuse you?
        Naw, I'm glad you understood my question in the first place. I'm taking an intro to web pub class, and we're basically just learning HTML and XHTML this semster. But the problem is, we don't get into CSS or Java till the end of the semester. Actually, I don't even think we get into Java till the 2nd year class. Just CSS, and like I said, that's a few-to-several weeks down the road.

        My problem is that I need to comprehend the "why" instead of the "just get it done" aspect of the style attribute, because when I have to take the final at the end of the year, I don't think we're allowed to use reference material, and I'm sure it's going to be a hard project we have to design in class. And considering it's worth 1/5 of the overall grade, I really want to make sure I understand it the whole way there, instead of freaking out during the final. :P But I'm sure you know where I'm coming from with that.

        Anyway, I'll check out your site, and thanks for the help.

        Comment


        • #5
          Sort of an explantion:

          HTML is designed to markup content for structure, not display. However since it's initial conception, HTML has been basterized to include display attributes such as FONT and COLOR, as well as tags such as center and blink.

          At some point a few people came to their senses and realized that adding the ability to style pages by addiing new tags and attributes was corrupting the idea behind markup lanuages (you try being blind and reading font tag'd up pages with a text browser) and no styling this way was cumbersome and limited. Current html and xhtml specs have deprecated certain display oriented html goodies, meaning they won't be supported someday, so stop using them. The style attribute within the body tag is really only there to bridge the gap between the way people are used to doing things and the way the w3c wants them to be doing things -> with style sheets independant of the logically formated html. The big idea is to keep display information and content seperate, but for now, thats just not going to happen.

          EIther way, the head tag techniclly shouldn't have a style attribute since nothing withing the head tags is displayed on screen.
          SIGNATURE PROTEST: KEEP THE SHORT FFS

          Comment


          • #6
            Originally posted by Benno
            Sort of an explantion:

            HTML is designed to markup content for structure, not display. However since it's initial conception, HTML has been basterized to include display attributes such as FONT and COLOR, as well as tags such as center and blink.

            At some point a few people came to their senses and realized that adding the ability to style pages by addiing new tags and attributes was corrupting the idea behind markup lanuages (you try being blind and reading font tag'd up pages with a text browser) and no styling this way was cumbersome and limited. Current html and xhtml specs have deprecated certain display oriented html goodies, meaning they won't be supported someday, so stop using them. The style attribute within the body tag is really only there to bridge the gap between the way people are used to doing things and the way the w3c wants them to be doing things -> with style sheets independant of the logically formated html. The big idea is to keep display information and content seperate, but for now, thats just not going to happen.

            EIther way, the head tag techniclly shouldn't have a style attribute since nothing withing the head tags is displayed on screen.
            Shit, I did write <head style=""> didn't I. OOps. I meant <body style="">. My bad.

            In any event, thank you, that makes a lot of sense. Yea, we've talked a little bit about the needs of text and aural browsers for people with handicaps, so I appreciate the more in-depth answer you gave. It's good to know. So you're saying the W3C's philosophy is to hopefully move away from embedding the style within the tags as much as possible? Interesting.

            I think one of the things I'm trying to figure out is with all the different tags, does that mean there's more than one way to way to write certain things, and they come out the same, and they appear the same when rendered by most browsers? Like, sometimes you can embed an attribute within the style section, or you could list it seperately if you wanted to, and there wouldn't be any consequenses asthetically nor functionally?

            Comment


            • #7
              Is anyone here really well familiarized with CSS? I need some help editting my MySpace profile.
              Originally posted by Jeenyuss
              sometimes i thrust my hips so my flaccid dick slaps my stomach, then my taint, then my stomach, then my taint. i like the sound.

              Comment


              • #8
                If you don't get help, ask me in April or May. We should have covered that part by then. Btw, had a conference with my Prof today and she explained the answer to my question. Basically, the <table> style attribute is deprecated, and that's why we were using it. I guess the W3C is trying to move toward using CSS for style, so basically, the stuff I have a question about I won't really need to worry about anyway.

                Edit: I think that's the point Saturn and Benno were trying to make. Thanks dudes for the help.

                <!-- I am a newb. Please be gentle. -->
                Last edited by Subjugation; 02-23-2005, 03:53 AM.

                Comment


                • #9
                  I'm a year off from graduating with a BS in this silly web stuff and editing css for packaged blogs is still pretty hard for me. I've tried to do stuff for jerome's old blog in the past and inconsistent browser support and uncommented css made it harder than writting a css doc from scratch.

                  I think one of the things I'm trying to figure out is with all the different tags, does that mean there's more than one way to way to write certain things, and they come out the same, and they appear the same when rendered by most browsers? Like, sometimes you can embed an attribute within the style section, or you could list it seperately if you wanted to, and there wouldn't be any consequenses asthetically nor functionally?
                  It's like english, you can say the same thing many differnt ways, but the words you choose can be verbose and thick, or concise and thin. The real power from css isn't from seperating content from display, it's the centralization of your design. An external css document can be linked to by any number of html documents. If, for example, you wanted to make all your <p> tags with an id="body_content" to have a 14 point trebuchet font with a green background, it would be alot easier to write it once in css than busting out the old font tag for ever instance of body content.

                  The table tag isn't deprecated, it's just used for layout; it's not ment for that. Tables are still needed for tabular data.

                  If you need a decent quick refrence for html tags, I like to use HTML Dog, it's alot faster than w3schools.
                  SIGNATURE PROTEST: KEEP THE SHORT FFS

                  Comment


                  • #10
                    double post
                    SIGNATURE PROTEST: KEEP THE SHORT FFS

                    Comment


                    • #11
                      Originally posted by Benno
                      The table tag isn't deprecated, it's just used for layout; it's not ment for that. Tables are still needed for tabular data.
                      No, I didn't mean the <table> tag is deprecated, the style attribute within the table tag is what my prof said was deprecated.

                      Comment


                      • #12
                        Originally posted by Benno
                        inconsistent browser support
                        Mainly IE. It doesn't even have a built function to let you select alternate stylesheets (which I think is a W3 standard). So that makes people have to use Javascript to select alternate stylesheets when they shouldn't have to.

                        I hate IE.

                        Originally posted by Benno
                        The table tag isn't deprecated, it's just used for layout; it's not ment for that. Tables are still needed for tabular data.
                        Yeah, but CSS3 has built in table support if I remember correctly (of course CSS3 support isn't great right now). No more "fake tables" with specially formatted <div>'s!

                        Originally posted by jesus=terrorist
                        No, I didn't mean the <table> tag is deprecated, the style attribute within the table tag is what my prof said was deprecated.
                        I wouldn't think so. In HTML 4.01 and XHTML Strict, the "align" and "bgcolor" attributes are deprecated. "Style" a standard attribute for any tag and shouldn't deprecated (and isn't in according to w3schools.com).
                        Ferengi Rule of Acquisition #98: Every man has his price.

                        Comment

                        Working...
                        X