HTML STYLE

Maha



HTML Style

  • HTML <style> attribute is used to add styles to an element, such as color, font, size, and etc.
  • The <style> tag in html can helps us to modify and edit our text but also we can change the style of a body or part of a page using CSS.

Syntax:

<tagname style ="property: value;">

What Are The Styles In HTML

Example:

  
  <!DOCTYPE html>
  <html>  
  <body>
  <p style ="colorred;">Gocourse</p>
  <p style ="colorpink;">Gocourse</p>
  <p style ="colorgreen;">Gocourse</p>
  <p style ="colorblue;">Gocourse</p>
  </body>  
  </html>


Output:




Text Color:

  • The text color can be altered using the CSS color to your web page.
  • If you want to quickly see how to add the color of your text.
  • Hexadecimal, RGB, HSL, and color names are all acceptable values for this property.
  • For instance, you can use the name skyblue, the hex code #87CEEB, the RGB decimal code rgb(135,206,235), or the HSL value hsl (197, 71%, 73%), to change the text's color to sky blue.

Example:


  <!DOCTYPE html>
  <html>
  <body>
  <h1 style ="colorblue;">HTML</h1>
  <p style ="colorskyblue;">Welcome to Gocourse!</p>
  <p style ="color#87CEEB;">Welcome to Gocourse!</p>
  <p style ="colorrgb(134,204,235);">Welcome to Gocourse!</p>
  <p style ="colorhsl(197, 71%,73%);">Welcome to  Gocourse!</p>
  </body>
  </html>


Output:




Background Color:

  • This background-color property defines the background for the HTML element.
  • The style attribute, with the CSS property background-color use inside the body tag of the HTML document. 


Example:

 
  <!DOCTYPE html>
  <html>
  <body style ="background-colorpink;">
  <h1>HTML</h1>
  <p> This is my html page.</p>
  </body>
  </html>


Output:




Text Alignment:

  • Alignment of the text using the text-align property. We can align the text in the Center, Right, Left.
  • To move a text at center position or wherever using the text-align tag. which is to be displayed on a web page.


Example: Text align in center

  
  <!DOCTYPE html>
  <html>
  <head>
  <title>Text alignment</title>
  </head>
  <body>
  <h1 style ="text-aligncenter;">GOCOURSE</h1>
  <h1 style ="font-sizemedium;"></h1>
  <p style ="text-aligncenter;">Use text-align for text alignment</p>  
  </body>
  </html>


Output:



Example: Text align in right

  
  <!DOCTYPE html>
  <html>
  <head>
  <title>Text alignment</title>
  </head>
  <body>
  <h1 style ="text-alignright;">GOCOURSE</h1>
  <p style ="text-alignright;">Use text-align for text alignment</p>
  </body>
  </html>


Output:



Example: Text align in left


  <!DOCTYPE html>
  <html>
  <head>
  <title>Text alignment</title>
  </head>
  <body>
  <h1 style ="text-alignleft;">GOCOURSE</h1>
  <p style ="text-alignleft;">Use text-align for text alignment</p> </body>
  </html>


Output:



Text size:

  • The style property in HTML to specify the font-size.
  • An element's inline style is specified through the style property. 
  • The attribute can use with the CSS property font-size and the HTML <p> tag. 
  • Since the <font> tag is not supported by HTML5, font size is added using the CSS style.

Example:


  <!DOCTYPE html>
  <html>    
  <head>      
  <title>HTML</title>    
  </head>    
  <body>      
  <h1 style ="font-size: 50px;">HTML Font-size</h1>      
  <p style ="font-size80px;">This is HTML font-size </p>    
  </body>
  </html>


Output:





Text Color:    

  • HTML text color defines the text color for the paragraph.                                 
  • It specify internal style for an element, with the CSS property color to set font color in HTML.

Example:


  <!DOCTYPE html>
  <html>
  <body>
  <h1 style ="colorblue;">HTML</h1>
  <style ="colorred;">HyperText Markup Language</p>
  </body>
  </html>


Output:





More topic in HTML

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send