Style in HTML

In HTML (Hypertext Markup Language), “style” refers to the presentation and visual appearance of elements on a web page. HTML is a markup language used to structure the content of a webpage, but it doesn’t handle the actual design or layout of the page. Instead, the styling of HTML elements is accomplished using CSS (Cascading Style Sheets).

CSS is a separate language that works in conjunction with HTML, allowing web developers to define how various HTML elements should be displayed on the page. By using CSS, you can control attributes such as colors, fonts, spacing, alignment, borders, and more.

There are three methods used to style HTML elements:

  1. Inline styles: You can apply styles directly to an individual HTML element using the “style” attribute. For example:
 <p style="color: blue; font-size: 16px;">This is a paragraph.</p>
HTML

  1. Internal styles: You can define styles within the section of your HTML document using the tag. These styles will apply to all elements with matching selectors. For example:
<head>
  <style>
     p {
      color: blue;
      font-size: 16px;
      }
  </style>
</head>
<body>
  <p>This is a paragraph with internal styles.</p>
</body>
HTML

  1. External styles: You can link an external CSS file to your HTML document using the “ tag. This is the most common approach for separating the content (HTML) from the presentation (CSS). For example, in your HTML file:
<head>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <p>This is a paragraph with external styles.</p>
</body>
HTML

And in the “styles.css” file:

p {
  color: blue;
  font-size: 16px;
}
HTML

Using CSS, you can apply styles to specific HTML elements or groups of elements, making it easier to create consistent and visually appealing web pages. Styles can be as simple or complex as needed, depending on the design requirements of your website.

Read in Hindi: HTML Style in Hindi

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *