CSS full guide


SUBMITTED BY: sharfudeen

DATE: May 25, 2016, 3:31 p.m.

FORMAT: CSS

SIZE: 4.1 kB

HITS: 1198

  1. h1 {
  2. font-family: Verdana, sans-serif; /* options if one font is not installed on the comuter */
  3. color: #576D94;
  4. }
  5. img {
  6. height:100px; /* height of the image */
  7. width: 300px; /* width of the image */
  8. border: 1px solid #4682b4; /* setting border to the image */
  9. }
  10. a {
  11. text-decoration: none; /* Removes underline in links */
  12. color: #cc0000; /* changes the color of the link */
  13. }
  14. /* <body>
  15. <h3>I'm plain old font!</h3>
  16. <div>
  17. <h3>Me, too!</h3>
  18. <div>
  19. <h3>Me three!</h3>
  20. <div>
  21. <h3>Forget you guys. I'm about to be red!</h3>
  22. </div>
  23. </div>
  24. </div>
  25. </body> */
  26. /* To select the inner i.e., third h3 to format */
  27. div div div h3 {
  28. color: red;
  29. }
  30. * {
  31. border: 1px dashed #3a5fcd;
  32. } /* "*" is a universal selector, it'll change/aplly the effect to all the elements of the page */
  33. /*<body>
  34. <p>Introduction: Cascading with CSS</p>
  35. <div>
  36. <p>Synopsis: When you set a property of a selector like 'p' to a certain value, that value applies to <em>all</em> p tags.
  37. If, however, you change that same property to a different value for a more specific instance of p,
  38. that change will <em>override</em> the 'general rule'.
  39. </p>
  40. <ul>
  41. <li><p>If you say p { font-family: Garamond}, all 'p's will have the font Garamond.</p></li>
  42. <li><p>BUT if you say li p {font-family: Verdana}, 'p's outside of 'li's will be
  43. in Garamond, and 'p's INSIDE 'li's will be in Verdana.
  44. </p></li>
  45. <li><p>The more specific your selectors are, the higher importance CSS gives to the styling you apply!</p></li>
  46. </ul>
  47. </div>
  48. <p>Summary: Greater specificity makes CSS prioritize that particular styling.</p>
  49. </body> */
  50. body > p {
  51. font-weight: bold; /* only select the direct paragrah and leaves the nested paragrhs */
  52. }
  53. div > p {
  54. color: #7ac5cd;
  55. }
  56. ul p {
  57. color: #000000;
  58. text-decoration: underline; /* underline */
  59. }
  60. /* Create button using div
  61. <div> </div> */
  62. div {
  63. border-style: solid;
  64. border-width: 2px;
  65. border-radius: 5px;
  66. height: 50px;
  67. width: 120px;
  68. border-color: #6495ed;
  69. background-color: #BCD2EE;
  70. }
  71. /* Pesudo-class selectors */
  72. /* for links
  73. a:link
  74. a:visited
  75. a:hover
  76. */
  77. a:link {
  78. color: #008b45; /*Color of the link before visiting the link */
  79. text-decoration: none; /* Removes the line on links */
  80. }
  81. a:hover {
  82. color: #00ff00; /* Color of the link when hovering mouse over the link */
  83. text-decoration: none; /* Removes the line while hovering mouse over the link */
  84. }
  85. a:visited {
  86. color: #ee9a00; /* Color of the visited link */
  87. }
  88. /* for child */
  89. /* <body>
  90. <div>
  91. <p>I'm the first child!</p>
  92. <p>We're not.</p>
  93. <p>We're not.</p>
  94. <p>We're not.</p>
  95. <p>We're not.</p>
  96. <p>We're not.</p>
  97. <p>We're not.</p>
  98. </div>
  99. </body> */
  100. p:first-child {
  101. font-family: cursive; /* Changes the style of first child only */
  102. }
  103. /* Changes the style for "n"th element/style */
  104. p:nth-child(2) {
  105. font-family: Tahoma;
  106. }
  107. p:nth-child(3) {
  108. color: #cc0000;
  109. }
  110. p:nth-child(4) {
  111. background-color: #00ff00;
  112. }
  113. p:nth-child(5) {
  114. font-size: 22px;
  115. }
  116. div {
  117. display: inline-block;
  118. margin-left: 5px;
  119. height: 100px;
  120. width: 100px;
  121. border-radius: 100%; /* it is used to make the div as round/circle shape if the height and width are same */
  122. border: 2px solid black;
  123. }
  124. /* blocks */
  125. /* <body>
  126. <div id="one"></div>
  127. <div id="two"></div>
  128. <div id="three"></div>
  129. <div id="four"></div>
  130. </body> */
  131. div {
  132. height: 50px;
  133. width: 100px;
  134. border: 2px solid black;
  135. border-radius: 5px;
  136. display: inline-block; /* Inlin-block is used to display the divisions next to the one and "display: block; " is used to display the divisions in below
  137. the first division The "display: inline" value places all your elements next to one another, but not as blocks: they don't keep their dimensions.
  138. "display: none " will hide borders. */
  139. }

comments powered by Disqus