Results 1 to 6 of 6

Thread: Style HTML Elements With Specific Attributes

  1. #1
    Join Date
    Aug 2006
    Posts
    222

    Style HTML Elements With Specific Attributes

    I am doing HTML from last three months. I have done many things in HTML. I have created many forms for different purpose. But I am not cleared in the Style HTML Elements With Specific Attributes.! There are many doubts in my mind about it. The main thing I want to know, is it possible to style HTML elements that have specific attributes..?? Also every browser supports the !DOCTYPE.?? Please help me to solve my query as soon as possible.
    Just a reply to say thank you for these links and posts I have a lot to read and learn now!



  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Style HTML Elements With Specific Attributes

    You can use the Style HTML Elements With Specific Attributes. Also it is possible to style HTML elements that have specific attributes, not just class and id. HTML is the predominant markup language for web pages. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists etc as well as for links, quotes, and other items. If you want to change the way the generated HTML output looks, you can do that with a Cascading Style Sheet (CSS), which modern browsers support. You use a text editor to create a separate CSS stylesheet file that contains all the style information, and then associate that stylesheet with all of your HTML files.

  3. #3
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Style HTML Elements With Specific Attributes

    You have asked that if !DOCTYPE is supported by every browser. The answer for this is that if you are having Internet Explorer 7 or higher version then it will supports attribute selectors only if a !DOCTYPE is specified. Attribute selection is NOT supported in IE6 and lower. I have provided you with an example of the styles all elements with a title attribute. Here is sample of coding for that :
    Code:
    [title]
    {
    color:yellow;
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Style HTML Elements With Specific Attributes

    You can also list all the HTML Elements inside a DIV with specific attributes. The following coding will output list of a tags inside the div2.
    Code:
    function getElementsByAttr(attr, value, parent)
    {
      var collection = parent.getElementsByTagName('#'),
        list = [];
      for (var i = 0, len = collection.length, curr; i < len; i++)
      {
        curr = collection[i];
        if (typeof curr[attr] != 'unknown' && curr[attr] === value)
        {
              list.push(curr);
        }
      }
      return list;
    
    }
    
    window.onload = function(){
      var list = getElementsByAttr('tata', 'tab3', document.getElementById
    ('div2'));

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Style HTML Elements With Specific Attributes

    You write your css stylesheet to associate CSS styles with specific combination of HTML element names. The following example mentioned below styles all elements with title="Welcome". Here is the coding for the same :
    Code:
    [title=Welcome]
    {
    border:7px solid red;
    }

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Style HTML Elements With Specific Attributes

    I think that you should have known that you can use the Style HTML Elements With Specific Attributes. You use a text editor to create a separate CSS stylesheet file that contains all the style information, and then associate that stylesheet with all of your HTML files. The The attribute selectors are particularly useful for styling forms without class or ID :
    Code:
    input[type="text"]
    {
    width:200px;
    display:block;
    margin-bottom:12px;
    background-color:blue;
    }
    input[type="button"]
    {
    width:150px;
    margin-left:30px;
    display:block;
    }

Similar Threads

  1. Powerpoint 2010 - Style attributes problem
    By Ayuka in forum Windows Software
    Replies: 5
    Last Post: 15-10-2010, 01:31 AM
  2. How to Add and Remove HTML elements Dynamically In Javascript?
    By Level8 in forum Software Development
    Replies: 5
    Last Post: 20-02-2010, 06:48 PM
  3. Need Semantic HTML tags and attributes
    By Muwafaq in forum Software Development
    Replies: 5
    Last Post: 17-02-2010, 12:44 AM
  4. <iframe> tag Standard Attributes for HTML
    By Jesus-Ernesto in forum Software Development
    Replies: 3
    Last Post: 08-12-2009, 02:31 AM
  5. Display HTML in XSL Style Sheet
    By Neil'o in forum Software Development
    Replies: 2
    Last Post: 27-03-2009, 09:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,864,508.59411 seconds with 17 queries