What is a <style> tag?
Experience Level: Junior
Tags: HTML
Answer
The <style>
tag is used to define styles for the HTML document. It usually contains CSS styles.
- It is a best practice to put the
<style>
tag to the<head>
element. It can be present in the<body>
element as well, but placing it to<head>
element is preferred. - The content of the
<style>
tag can be present either directly in the document (embedded) or it can be linked from the external file. - Linking the styles from the external file is the preferred method as the external file can be downloaded just once and then cached, so less data need to be transferred on subsequent web page loads.
- There can be multiple
<style>
tags present in the HTML page.
Related HTML job interview questions
What is a <html> tag?
HTML JuniorWhat are <h1>...<h6> tags?
HTML JuniorWhat is a <title> tag?
HTML JuniorWhat is a <head> tag?
HTML JuniorWhat is a <button> tag?
HTML Junior