Layout-neutral tag for CSS?

前端 未结 8 1942
执笔经年
执笔经年 2021-01-05 05:14

Is there an \"invisible\" tag in HTML (4) that I can use to make CSS distinctions

tag.myclass tag.mysubclass h1 {  } 

without having

相关标签:
8条回答
  • 2021-01-05 05:47

    I think you want a <fieldset>.

    0 讨论(0)
  • 2021-01-05 05:57

    No, there is not.

    (And that's because such an element wouldn't really fit into the rest of HTML. The only reason DIV and SPAN affect the surrounding area is because they're block and inline elements, respectively. What would an 'invisible' element be? If you need something that's completely independent, absolutely (or relatively) position it and give it a higher z-index.)

    0 讨论(0)
  • 2021-01-05 05:58

    I'd say a span tag is as neutral as they come. I don't think there's any browser that applies a margin nor a padding and it just wraps around it's contents.

    0 讨论(0)
  • 2021-01-05 05:58

    The right answer is use a div tag and define a class for it. Here is an example:

    <h2 style="font-size: 14px">Project 1 - Project 2 
      <div class="username">{% if request.user.is_authenticated%} Welcome {{request.user.username}} {% endif %}</div>
    </h2>
    

    then in your css file you can have a class like this:

    .username {
        color:white; 
        float:right;
        padding-right: 100px;
    }
    

    voila!! It all belongs to h2 tag but the user name has a different css applied.

    0 讨论(0)
  • 2021-01-05 06:02

    If you want to group elements use a div or a span tag as a wrapper element. Apply your id or class to this, and style it accordingly.

    EDIT

    There isn't an 'invisible' tag - but margins and padding can be easily reset 'margin: 0; padding: 0;'

    0 讨论(0)
  • 2021-01-05 06:02

    You can add display: none; to it. That won't display it (obviously).

    0 讨论(0)
提交回复
热议问题