Advertisement
Najeebsk

HTML-STYLES-CSS-PART-2

Jan 5th, 2022
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 23.18 KB | None | 0 0
  1. TITLE: HTML Styles - CSS PART-2
  2. TAGS: Examples
  3. TIME: 9:56 AM Thursday, January 06, 2022
  4. CONTENT: CSS Padding
  5. -----------------------------
  6. Padding - Individual Sides
  7. CSS has properties for specifying the padding for each side of an element:
  8.     padding-top
  9.     padding-right
  10.     padding-bottom
  11.     padding-left
  12. All the padding properties can have the following values:
  13.     length - specifies a padding in px, pt, cm, etc.
  14.     % - specifies a padding in % of the width of the containing element
  15.     inherit - specifies that the padding should be inherited from the parent element
  16. Example
  17. Set different padding for all four sides of a <div> element:  
  18. div {
  19.   padding-top: 50px;
  20.   padding-right: 30px;
  21.   padding-bottom: 50px;
  22.   padding-left: 80px;
  23. }
  24. Padding - Shorthand Property
  25. To shorten the code, it is possible to specify all the padding properties in one property.
  26. The padding property is a shorthand property for the following individual padding properties:
  27.     padding-top
  28.     padding-right
  29.     padding-bottom
  30.     padding-left
  31. So, here is how it works:
  32. If the padding property has four values:
  33.     padding: 25px 50px 75px 100px;
  34.         top padding is 25px
  35.         right padding is 50px
  36.         bottom padding is 75px
  37.         left padding is 100px
  38. Example
  39. Use the padding shorthand property with four values:
  40. div {
  41.   padding: 25px 50px 75px 100px;
  42. }
  43. If the padding property has three values:
  44.     padding: 25px 50px 75px;
  45.         top padding is 25px
  46.         right and left paddings are 50px
  47.         bottom padding is 75px
  48. Example
  49. Use the padding shorthand property with three values:
  50. div {
  51.   padding: 25px 50px 75px;
  52. }
  53. If the padding property has two values:
  54.     padding: 25px 50px;
  55.         top and bottom paddings are 25px
  56.         right and left paddings are 50px
  57. Example
  58. Use the padding shorthand property with two values:
  59. div {
  60.   padding: 25px 50px;
  61. }
  62. If the padding property has one value:
  63.     padding: 25px;
  64.         all four paddings are 25px
  65. Example
  66. Use the padding shorthand property with one value:
  67. div {
  68.   padding: 25px;
  69. }
  70. Padding and Element Width
  71. The CSS width property specifies the width of the element's content area. The content area is the portion inside the padding, border, and margin of an element (the box model).
  72. So, if an element has a specified width, the padding added to that element will be added to the total width of the element. This is often an undesirable result.
  73. Example
  74. Here, the <div> element is given a width of 300px. However, the actual width of the <div> element will be 350px (300px + 25px of left padding + 25px of right padding):
  75. div {
  76.  width: 300px;
  77.  padding: 25px;
  78. }
  79. To keep the width at 300px, no matter the amount of padding, you can use the box-sizing property. This causes the element to maintain its actual width; if you increase the padding, the available content space will decrease.
  80. Example
  81. Use the box-sizing property to keep the width at 300px, no matter the amount of padding:
  82. div {
  83.  width: 300px;
  84.  padding: 25px;
  85.  box-sizing: border-box;
  86. }
  87. All CSS Padding Properties
  88. Property    Description
  89. padding     A shorthand property for setting all the padding properties in one declaration
  90. padding-bottom  Sets the bottom padding of an element
  91. padding-left    Sets the left padding of an element
  92. padding-right   Sets the right padding of an element
  93. padding-top     Sets the top padding of an element
  94. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  95. CSS Height and Width
  96. ------------------------------------------------
  97. CSS height and width Values
  98. The height and width properties may have the following values:
  99.    auto - This is default. The browser calculates the height and width
  100.    length - Defines the height/width in px, cm etc.
  101.    % - Defines the height/width in percent of the containing block
  102.    initial - Sets the height/width to its default value
  103.    inherit - The height/width will be inherited from its parent value
  104. Example
  105. Set the height and width of a <div> element:
  106. div {
  107.  height: 200px;
  108.  width: 50%;
  109.  background-color: powderblue;
  110. }
  111. Example
  112. Set the height and width of another <div> element:
  113. div {
  114.  height: 100px;
  115.  width: 500px;
  116.  background-color: powderblue;
  117. }
  118. Example
  119. This <div> element has a height of 100 pixels and a max-width of 500 pixels:
  120. div {
  121.  max-width: 500px;
  122.  height: 100px;
  123.  background-color: powderblue;
  124. }
  125. All CSS Dimension Properties
  126. Property    Description
  127. height  Sets the height of an element
  128. max-height  Sets the maximum height of an element
  129. max-width   Sets the maximum width of an element
  130. min-height  Sets the minimum height of an element
  131. min-width   Sets the minimum width of an element
  132. width   Sets the width of an element
  133. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  134. CSS Box Model
  135. ------------------------------
  136. Example
  137. Demonstration of the box model:
  138. div {
  139.  width: 300px;
  140.  border: 15px solid green;
  141.  padding: 50px;
  142.  margin: 20px;
  143. }
  144. Example
  145. This <div> element will have a total width of 350px:
  146. div {
  147.  width: 320px;
  148.  padding: 10px;
  149.  border: 5px solid gray;
  150.  margin: 0;
  151. }
  152. Here is the calculation:
  153. 320px (width)
  154. + 20px (left + right padding)
  155. + 10px (left + right border)
  156. + 0px (left + right margin)
  157. = 350px
  158. The total width of an element should be calculated like this:
  159. Total element width = width + left padding + right padding + left border + right border + left margin + right margin
  160. The total height of an element should be calculated like this:
  161. Total element height = height + top padding + bottom padding + top border + bottom border + top margin + bottom margin
  162. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  163. CSS Outline
  164. -------------------------------
  165. CSS has the following outline properties:
  166.    outline-style
  167.    outline-color
  168.    outline-width
  169.    outline-offset
  170.    outline
  171. CSS Outline Style
  172. --------------------------------
  173. The outline-style property specifies the style of the outline, and can have one of the following values:
  174.    dotted - Defines a dotted outline
  175.    dashed - Defines a dashed outline
  176.    solid - Defines a solid outline
  177.    double - Defines a double outline
  178.    groove - Defines a 3D grooved outline
  179.    ridge - Defines a 3D ridged outline
  180.    inset - Defines a 3D inset outline
  181.    outset - Defines a 3D outset outline
  182.    none - Defines no outline
  183.    hidden - Defines a hidden outline
  184. The following example shows the different outline-style values:
  185. Example
  186. Demonstration of the different outline styles:
  187. p.dotted {outline-style: dotted;}
  188. p.dashed {outline-style: dashed;}
  189. p.solid {outline-style: solid;}
  190. p.double {outline-style: double;}
  191. p.groove {outline-style: groove;}
  192. p.ridge {outline-style: ridge;}
  193. p.inset {outline-style: inset;}
  194. p.outset {outline-style: outset;}
  195. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  196. CSS Outline Width
  197. -------------------------------
  198. The outline-width property specifies the width of the outline, and can have one of the following values:
  199.    thin (typically 1px)
  200.    medium (typically 3px)
  201.    thick (typically 5px)
  202.    A specific size (in px, pt, cm, em, etc)
  203. The following example shows some outlines with different widths:
  204. Example
  205. p.ex1 {
  206.  border: 1px solid black;
  207.  outline-style: solid;
  208.  outline-color: red;
  209.  outline-width: thin;
  210. }
  211.  
  212. p.ex2 {
  213.  border: 1px solid black;
  214.  outline-style: solid;
  215.  outline-color: red;
  216.  outline-width: medium;
  217. }
  218.  
  219. p.ex3 {
  220.  border: 1px solid black;
  221.  outline-style: solid;
  222.  outline-color: red;
  223.  outline-width: thick;
  224. }
  225.  
  226. p.ex4 {
  227.  border: 1px solid black;
  228.  outline-style: solid;
  229.  outline-color: red;
  230.  outline-width: 4px;
  231. }
  232. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  233. CSS Outline Color
  234. -------------------------------------
  235. The outline-color property is used to set the color of the outline.
  236. The color can be set by:
  237.    name - specify a color name, like "red"
  238.    HEX - specify a hex value, like "#ff0000"
  239.    RGB - specify a RGB value, like "rgb(255,0,0)"
  240.    HSL - specify a HSL value, like "hsl(0, 100%, 50%)"
  241.    invert - performs a color inversion (which ensures that the outline is visible, regardless of color background)
  242. The following example shows some different outlines with different colors. Also notice that these elements also have a thin black border inside the outline:
  243. Example
  244. p.ex1 {
  245.  border: 2px solid black;
  246.  outline-style: solid;
  247.  outline-color: red;
  248. }
  249. p.ex2 {
  250.  border: 2px solid black;
  251.  outline-style: dotted;
  252.  outline-color: blue;
  253. }
  254. p.ex3 {
  255.  border: 2px solid black;
  256.  outline-style: outset;
  257.  outline-color: grey;
  258. }
  259. HEX Values
  260. The outline color can also be specified using a hexadecimal value (HEX):
  261. Example
  262. p.ex1 {
  263.  outline-style: solid;
  264.  outline-color: #ff0000; /* red */
  265. }
  266. RGB Values
  267. Or by using RGB values:
  268. Example
  269. p.ex1 {
  270.  outline-style: solid;
  271.  outline-color: rgb(255, 0, 0); /* red */
  272. }
  273. HSL Values
  274. You can also use HSL values:
  275. Example
  276. p.ex1 {
  277.  outline-style: solid;
  278.  outline-color: hsl(0, 100%, 50%); /* red */
  279. }
  280. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  281. CSS Outline Shorthand
  282. -------------------------------------------
  283. CSS Outline - Shorthand property
  284. The outline property is a shorthand property for setting the following individual outline properties:
  285.    outline-width
  286.    outline-style (required)
  287.    outline-color
  288. The outline property is specified as one, two, or three values from the list above. The order of the values does not matter.
  289. The following example shows some outlines specified with the shorthand outline property:
  290. Example
  291. p.ex1 {outline: dashed;}
  292. p.ex2 {outline: dotted red;}
  293. p.ex3 {outline: 5px solid yellow;}
  294. p.ex4 {outline: thick ridge pink;}
  295. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  296. CSS Outline Offset
  297. --------------------------------------
  298. The outline-offset property adds space between an outline and the edge/border of an element. The space between an element and its outline is transparent.
  299. The following example specifies an outline 15px outside the border edge:
  300. Example
  301. p {
  302.  margin: 30px;
  303.  border: 1px solid black;
  304.  outline: 1px solid red;
  305.  outline-offset: 15px;
  306. }
  307. Example
  308. p {
  309.  margin: 30px;
  310.  background: yellow;
  311.  border: 1px solid black;
  312.  outline: 1px solid red;
  313.  outline-offset: 15px;
  314. }
  315. All CSS Outline Properties
  316. Property    Description
  317. outline     A shorthand property for setting outline-width, outline-style, and outline-color in one declaration
  318. outline-color   Sets the color of an outline
  319. outline-offset  Specifies the space between an outline and the edge or border of an element
  320. outline-style   Sets the style of an outline
  321. outline-width   Sets the width of an outline
  322. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  323. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  324. TITLE: HTML Styles - CSS PART-2
  325. TAGS: Examples
  326. TIME: 10:17 AM Thursday, January 06, 2022
  327. CONTENT: CSS Text
  328. -----------------------
  329. Text Color
  330. The color property is used to set the color of the text. The color is specified by:
  331.    a color name - like "red"
  332.    a HEX value - like "#ff0000"
  333.    an RGB value - like "rgb(255,0,0)"
  334. Look at CSS Color Values for a complete list of possible color values.
  335. The default text color for a page is defined in the body selector.
  336. Example
  337. body {
  338.  color: blue;
  339. }
  340.  
  341. h1 {
  342.  color: green;
  343. }
  344. Text Color and Background Color
  345. In this example, we define both the background-color property and the color property:
  346. Example
  347. body {
  348.  background-color: lightgrey;
  349.  color: blue;
  350. }
  351.  
  352. h1 {
  353.  background-color: black;
  354.  color: white;
  355. }
  356.  
  357. div {
  358.  background-color: blue;
  359.  color: white;
  360. }
  361. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  362. CSS Text Alignment
  363. ------------------------------------
  364. Text Alignment
  365. The text-align property is used to set the horizontal alignment of a text.
  366. A text can be left or right aligned, centered, or justified.
  367. The following example shows center aligned, and left and right aligned text (left alignment is default if text direction is left-to-right, and right alignment is default if text direction is right-to-left):
  368. Example
  369. h1 {
  370.  text-align: center;
  371. }
  372.  
  373. h2 {
  374.  text-align: left;
  375. }
  376.  
  377. h3 {
  378.  text-align: right;
  379. }
  380. When the text-align property is set to "justify", each line is stretched so that every line has equal width, and the left and right margins are straight (like in magazines and newspapers):
  381. Example
  382. div {
  383.  text-align: justify;
  384. }
  385. Text Align Last
  386. The text-align-last property specifies how to align the last line of a text.
  387. Example
  388. Align the last line of text in three <p> elements:
  389. p.a {
  390.  text-align-last: right;
  391. }
  392.  
  393. p.b {
  394.  text-align-last: center;
  395. }
  396.  
  397. p.c {
  398.  text-align-last: justify;
  399. }
  400. Text Direction
  401. The direction and unicode-bidi properties can be used to change the text direction of an element:
  402. Example
  403. p {
  404.  direction: rtl;
  405.  unicode-bidi: bidi-override;
  406. }
  407. Vertical Alignment
  408. The vertical-align property sets the vertical alignment of an element.
  409. Example
  410. Set the vertical alignment of an image in a text:
  411. img.a {
  412.  vertical-align: baseline;
  413. }
  414. img.b {
  415.  vertical-align: text-top;
  416. }
  417.  
  418. img.c {
  419.  vertical-align: text-bottom;
  420. }
  421.  
  422. img.d {
  423.  vertical-align: sub;
  424. }
  425.  
  426. img.e {
  427.  vertical-align: super;
  428. }
  429. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  430. CSS Text Decoration
  431. -----------------------------------------
  432. Example
  433. a {
  434.  text-decoration: none;
  435. }
  436. The other text-decoration values are used to decorate text:
  437. Example
  438. h2 {
  439.  text-decoration: overline;
  440. }
  441.  
  442. h3 {
  443.  text-decoration: line-through;
  444. }
  445.  
  446. h4 {
  447.  text-decoration: underline;
  448. }
  449. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  450. CSS Text Transformation
  451. ------------------------------------------------
  452. Example
  453. p.uppercase {
  454.  text-transform: uppercase;
  455. }
  456.  
  457. p.lowercase {
  458.  text-transform: lowercase;
  459. }
  460.  
  461. p.capitalize {
  462.  text-transform: capitalize;
  463. }
  464. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  465. CSS Text Spacing Text Indentation
  466. ----------------------------------------------------------------
  467. Example 1 Text Indentation
  468. p {
  469.  text-indent: 50px;
  470. }
  471. Example 2 Letter Spacing
  472. h1 {
  473.  letter-spacing: 5px;
  474. }
  475.  
  476. h2 {
  477.  letter-spacing: -2px;
  478. }
  479. Example 3 Line Height
  480. p.small {
  481.  line-height: 0.8;
  482. }
  483.  
  484. p.big {
  485.  line-height: 1.8;
  486. }
  487. Example 4 Word Spacing
  488. p.one {
  489.  word-spacing: 10px;
  490. }
  491.  
  492. p.two {
  493.  word-spacing: -2px;
  494. }
  495. Example 5 White Space
  496. p {
  497.  white-space: nowrap;
  498. }
  499. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  500. CSS Text Shadow
  501. ---------------------------------------
  502. Example
  503. h1 {
  504.  text-shadow: 2px 2px;
  505. }
  506. Example
  507. h1 {
  508.  text-shadow: 2px 2px red;
  509. }
  510. Example
  511. h1 {
  512.  text-shadow: 2px 2px 5px red;
  513. }
  514. Example 1
  515. Text-shadow on a white text:
  516. h1 {
  517.  color: white;
  518.  text-shadow: 2px 2px 4px #000000;
  519. }
  520. Example 2
  521. Text-shadow with red neon glow:
  522. h1 {
  523.  text-shadow: 0 0 3px #ff0000;
  524. }
  525. Example 3
  526. Text-shadow with red and blue neon glow:
  527. h1 {
  528.  text-shadow: 0 0 3px #ff0000, 0 0 5px #0000ff;
  529. }
  530. Example 4
  531. h1 {
  532.  color: white;
  533.  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
  534. }
  535. All CSS Text Properties
  536. Property    Description
  537. color   Sets the color of text
  538. direction   Specifies the text direction/writing direction
  539. letter-spacing  Increases or decreases the space between characters in a text
  540. line-height     Sets the line height
  541. text-align  Specifies the horizontal alignment of text
  542. text-align-last     Specifies how to align the last line of a text
  543. text-decoration     Specifies the decoration added to text
  544. text-indent     Specifies the indentation of the first line in a text-block
  545. text-justify    Specifies how justified text should be aligned and spaced
  546. text-overflow   Specifies how overflowed content that is not displayed should be signaled to the user
  547. text-shadow     Specifies the shadow effect added to text
  548. text-transform  Controls the capitalization of text
  549. unicode-bidi    Used together with the direction property to set or return whether the text should be overridden to support multiple languages in the same document
  550. vertical-align  Sets the vertical alignment of an element
  551. white-space     Specifies how white-space inside an element is handled
  552. word-spacing    Increases or decreases the space between words in a text
  553. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  554. CSS Fonts
  555. ----------------------
  556. Generic Font Families
  557. In CSS there are five generic font families:
  558.    Serif fonts have a small stroke at the edges of each letter. They create a sense of formality and elegance.
  559.    Sans-serif fonts have clean lines (no small strokes attached). They create a modern and minimalistic look.
  560.    Monospace fonts - here all the letters have the same fixed width. They create a mechanical look.
  561.    Cursive fonts imitate human handwriting.
  562.    Fantasy fonts are decorative/playful fonts.
  563. Example
  564. Specify some different fonts for three paragraphs:
  565. .p1 {
  566.  font-family: "Times New Roman", Times, serif;
  567. }
  568.  
  569. .p2 {
  570.  font-family: Arial, Helvetica, sans-serif;
  571. }
  572.  
  573. .p3 {
  574.  font-family: "Lucida Console", "Courier New", monospace;
  575. }
  576. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  577. CSS Web Safe Fonts
  578. ------------------------------------------
  579. Example
  580. Here, there are three font types: Tahoma, Verdana, and sans-serif. The second and third fonts are backups, in case the first one is not found.
  581. p {
  582. font-family: Tahoma, Verdana, sans-serif;
  583. }
  584. Best Web Safe Fonts for HTML and CSS
  585. The following list are the best web safe fonts for HTML and CSS:
  586.    Arial (sans-serif)
  587.    Verdana (sans-serif)
  588.    Helvetica (sans-serif)
  589.    Tahoma (sans-serif)
  590.    Trebuchet MS (sans-serif)
  591.    Times New Roman (serif)
  592.    Georgia (serif)
  593.    Garamond (serif)
  594.    Courier New (monospace)
  595.    Brush Script MT (cursive)
  596. CSS Font Fallbacks
  597. ---------------------------------------
  598. Below are some commonly used font fallbacks, organized by the 5 generic font families:
  599.    Serif
  600.    Sans-serif
  601.    Monospace
  602.    Cursive
  603.    Fantasy
  604. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  605. CSS Font Style
  606. ------------------------------
  607. Font Style
  608. The font-style property is mostly used to specify italic text.
  609. This property has three values:
  610.    normal - The text is shown normally
  611.    italic - The text is shown in italics
  612.    oblique - The text is "leaning" (oblique is very similar to italic, but less supported)
  613. Example
  614. p.normal {
  615.  font-style: normal;
  616. }
  617.  
  618. p.italic {
  619.  font-style: italic;
  620. }
  621.  
  622. p.oblique {
  623.  font-style: oblique;
  624. }
  625. Font Weight
  626. The font-weight property specifies the weight of a font:
  627. Example
  628. p.normal {
  629.  font-weight: normal;
  630. }
  631.  
  632. p.thick {
  633.  font-weight: bold;
  634. }
  635. Font Variant
  636. The font-variant property specifies whether or not a text should be displayed in a small-caps font.
  637. In a small-caps font, all lowercase letters are converted to uppercase letters. However, the converted uppercase letters appears in a smaller font size than the original uppercase letters in the text.
  638. Example
  639. p.normal {
  640.  font-variant: normal;
  641. }
  642.  
  643. p.small {
  644.  font-variant: small-caps;
  645. }
  646. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  647. CSS Font Size
  648. ----------------------------
  649. Example
  650. h1 {
  651.  font-size: 40px;
  652. }
  653.  
  654. h2 {
  655.  font-size: 30px;
  656. }
  657.  
  658. p {
  659.  font-size: 14px;
  660. }
  661. Example
  662. h1 {
  663.  font-size: 2.5em; /* 40px/16=2.5em */
  664. }
  665.  
  666. h2 {
  667.  font-size: 1.875em; /* 30px/16=1.875em */
  668. }
  669.  
  670. p {
  671.  font-size: 0.875em; /* 14px/16=0.875em */
  672. }
  673. Example
  674. body {
  675.  font-size: 100%;
  676. }
  677.  
  678. h1 {
  679.  font-size: 2.5em;
  680. }
  681.  
  682. h2 {
  683.  font-size: 1.875em;
  684. }
  685.  
  686. p {
  687.  font-size: 0.875em;
  688. }
  689. Example
  690. <h1 style="font-size:10vw">Hello World</h1>
  691. CSS Google Fonts
  692. ---------------------------------------
  693. Example 1
  694. Here, we want to use a font named "Sofia" from Google Fonts:
  695. <head>
  696. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia">
  697. <style>
  698. body {
  699.  font-family: "Sofia", sans-serif;
  700. }
  701. </style>
  702. </head>
  703. Example 2
  704. Here, we want to use a font named "Trirong" from Google Fonts:
  705. <head>
  706. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Trirong">
  707. <style>
  708. body {
  709.  font-family: "Trirong", serif;
  710. }
  711. </style>
  712. </head>
  713. Example 3
  714. Here, we want to use a font named "Audiowide" from Google Fonts:
  715. <head>
  716. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Audiowide">
  717. <style>
  718. body {
  719.  font-family: "Audiowide", sans-serif;
  720. }
  721. </style>
  722. </head>
  723. Example 4
  724. Request multiple fonts:
  725. <head>
  726. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Audiowide|Sofia|Trirong">
  727. <style>
  728. h1.a {font-family: "Audiowide", sans-serif;}
  729. h1.b {font-family: "Sofia", sans-serif;}
  730. h1.c {font-family: "Trirong", serif;}
  731. </style>
  732. </head>
  733. Example
  734. Style the "Sofia" font:
  735. <head>
  736. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia">
  737. <style>
  738. body {
  739.  font-family: "Sofia", sans-serif;
  740.  font-size: 30px;
  741.  text-shadow: 3px 3px 3px #ababab;
  742. }
  743. </style>
  744. </head>
  745. <head>
  746. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia&effect=fire">
  747. <style>
  748. body {
  749.  font-family: "Sofia", sans-serif;
  750.  font-size: 30px;
  751. }
  752. </style>
  753. </head>
  754. <body>
  755. <h1 class="font-effect-fire">Sofia on Fire</h1>
  756. </body>
  757. <head>
  758. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple">
  759. <style>
  760. body {
  761.  font-family: "Sofia", sans-serif;
  762.  font-size: 30px;
  763. }
  764. </style>
  765. </head>
  766. <body>
  767. <h1 class="font-effect-neon">Neon Effect</h1>
  768. <h1 class="font-effect-outline">Outline Effect</h1>
  769. <h1 class="font-effect-emboss">Emboss Effect</h1>
  770. <h1 class="font-effect-shadow-multiple">Multiple Shadow Effect</h1>
  771. </body>
  772. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  773. CSS Great Font Pairings
  774. ---------------------------------------------
  775. Example
  776. No doubt "Georgia" is the boss here:
  777. body {
  778.  background-color: black;
  779.  font-family: Verdana, sans-serif;
  780.  font-size: 16px;
  781.  color: gray;
  782. }
  783.  
  784. h1 {
  785.  font-family: Georgia, serif;
  786.  font-size: 60px;
  787.  color: white;
  788. }
  789. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  790. CSS Font Property
  791. ------------------------------------
  792. The font property is a shorthand property for:
  793.    font-style
  794.    font-variant
  795.    font-weight
  796.    font-size/line-height
  797.    font-family
  798. Example
  799. Use font to set several font properties in one declaration:
  800. p.a {
  801.  font: 20px Arial, sans-serif;
  802. }
  803.  
  804. p.b {
  805.  font: italic small-caps bold 12px/30px Georgia, serif;
  806. }
  807. All CSS Font Properties
  808. Property    Description
  809. font    Sets all the font properties in one declaration
  810. font-family     Specifies the font family for text
  811. font-size   Specifies the font size of text
  812. font-style  Specifies the font style for text
  813. font-variant    Specifies whether or not a text should be displayed in a small-caps font
  814. font-weight     Specifies the weight of a font
  815. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=--=-=-=--=-=-=-=-=-=-=-
  816. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  817.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement