What is a <style> tag?
Experience Level: Junior
<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.