HTML
CSS
PHP
Deno
Examples
Do It Yourself
Blog
Type in your code below
Run
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>CSS Font Weight Example</title> <style> /* css-font-weight-intro-example1 */ /* Keyword values */ span.keyword { font-weight: normal; } button.keyword { font-weight: bold; } /* Keyword values that is relative to the parent element */ span.keyword-relative { font-weight: lighter; /* Make the font lighter than the parent's */ } button.keyword-relative { font-weight: bolder; /* Make the font lighter than the parent's */ } /* Numeric keyword values */ h1.number { font-weight: 400; /* normal */ } div.number { font-weight: 700; /* bold */ } /* *Note: You can use the font-weight number value from 100-900. Value: 400 means normal and Value: 900 means bold. */ /* Global values */ span.global { font-weight: inherit; } button.global { font-weight: initial; } div.global { font-weight: unset; } </style> </head> <body> <!-- Keywords value Preview --> <span class="keyword">This is a sample of <span> using a keyword value "bold".</span> <button class="keyword">This is a sample of <button> using a keyword value "normal".</button> <!-- Keywords relative value to parent Preview --> <span class="keyword-relative">This is a sample of <span> using a keyword relative value.</span> <button class="keyword-relative">This is a sample of <button> using a keyword relative value.</button> <!-- Numbers value Preview --> <h1 class="number">This is a sample of <h1> using a number value.</h1> <div class="number">This is a sample of <div> using a number value.</div> <!-- Global value Preview --> <span class="global">This is a sample of <span> using a global value.</span> <button class="global">This is a sample of <button> using a global value.</button> <div class="global">This is a sample of <div> using a global value.</div> </body> </html>
Related Chapters
CSS Fonts
CSS Text Styles
Related Examples
HTML Paragraph Text Example
HTML Bring Attention to Example
HTML Unarticulated Annotation (Underline) Example
HTML Idiomatic Text (Italics) Example