开发者

Can non styled HTML elements make any type of problem in document flow or any cross browser problem?

Should we write css to each element or only for those elements which want to give style?

like for example

  <div id="f开发者_开发知识库irst">
     <span class="one">
      <a href="#">content text</a>
     </span>
    </div>
<div id="second">
     <span class="two">
      <a href="#">content text</a>
     </span>
    </div>
<div id="third">
     <span class="three">
      <a href="#">content text</a>
     </span>
    </div>

I just want to show link text with a color.Should i write CSS for all elements

If i write css only for a (....) and nothing defines for #one and .two. will i can get any problem.

Can non styled HTML elements create any type of problem in document flow or any cross browser problem?


If you only need to apply style to the link, then you only need to write css for the link. If the class is not defined for the span or the div, then nothing will technically go wrong.


In order to style the link, you do not need to style any other elements. You could simply use:

a { color: red }

or whatever style you want. However, you'll be styling all link elements in the entire document. If you want to style only some links, you'll need to include more context in the CSS definition as well. For instance:

#one .two a { color: red }

Will style only the links inside something with the class two inside something with the id one.


No that shouldnt be a problem. In general you should keep your rules as concise as possible given the css required to produce the visual layout you need. if all you need to do is defin a link color then a simple:

a:link, a:visited {color: /* color */} a:hover, a:active {color: /* color */}

should suffice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜