style Tag in HTML


The `<style>` tag is used to define styles for HTML documents. It is an essential part of building modern websites and creating a consistent user interface.

Here’s a step-by-step tutorial on how to use the `<style>` tag:

Step 1: Open an HTML document
To begin, open a text editor and create a new HTML document. You can also use an HTML editor like Sublime Text, Visual Studio Code, or Notepad++. Make sure to save the file with the “.html” extension.

Step 2: Add the `<style>` tag
Next, add the `<style>` tag to the `<head>` section of your HTML document, like this:

<!DOCTYPE html>
/* CSS code goes here */
<!– HTML code goes here –>

Step 3: Write CSS code
Inside the `<style>` tag, you can write CSS code to style your HTML document. For example, you could change the background color of the body element like this:

body {
background-color: #f2f2f2;

You can also target specific HTML elements and apply styles to them. For example, you could change the font size of all headings like this:

Also Read:  del Tag in HTML

h1, h2, h3, h4, h5, h6 {
font-size: 24px;

Step 4: Apply styles to HTML elements
To apply the styles you’ve written to HTML elements, you need to use CSS selectors. For example, to apply the background color to the body element, you can use the following selector:

body {
background-color: #f2f2f2;

To apply a style to a specific HTML element, you need to select that element using its tag name, ID, or class. For example, to apply a border to an element with the ID “myDiv”, you can use the following selector:

#myDiv {
border: 1px solid black;

Step 5: Save and preview your HTML document
After you’ve written your CSS code and applied styles to HTML elements, save your HTML document and open it in a web browser to see how it looks. You can make further adjustments to your CSS code until you achieve the desired result.

That’s it! With the `<style>` tag, you can define styles for your HTML documents and create a customized user interface.

Previous articlestrong Tag in HTML
Next articlesub Tag in HTML
Namaskaar, Friends main Kapil ka Founder hu. Mere kai English blog bhi hai ,par mera motive yahan par easy language mein Technology se related Gyan ko aap tak pahunchane ka hai .taki aap kuch naya shikh sake. meri koshish hai ki bilkul simple tarike se aap ko nyi updates deta rahu taki aap bhi technology ke is yug mein peeche na rahe aur shikte rahe.Mujhse judne ke liye app mujhe Social Media par follow kar sakte hai.

Leave a Reply