HTML: Style Attribute

The style attribute is used to set the style of an HTML element. In HTML5, the style attribute can be used on any HTML element. Syntax: –

style=“property1: property1-value; property2: property2-value;” Where property is CSS property and Property-value is CSS value.

<html>
	<head>
		<title>Hello CSS</title>
	</head>
	<body>
	<h1 style= color:blue  font-size: 45em; >
                   I am Heading
        </h1>
	<p style= color:rgb(38,226,85) font-size: 40px; > 
                  I am 1st Para
        </p>
	<p>I am second Paragraph</p>
	</body>
</html>
Tagged : / / / / / /

HTML: Style Tag

The <style> tag is used to declare style sheets within the head of  HTML document. Inside the <style> element you specify how HTML elements should render in a browser. Each HTML document can contain multiple <style> tags.

AttributeValueDescription
mediamedia_querySpecifies what media/device the media resource is optimized for
scopedscopedSpecifies that the styles only apply to this element’s parent element and that element’s child elements
typetext/cssSpecifies the media type of the <style> tag
<html>
	<head>
		<title>html_style</title>
		
		</style>
	</head>
	<body style="background-color: rgb(180, 221, 67);">
	<h1 style="text-align: center;">Style tag</h1>
	<p style="margin-bottom: auto;">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, nobis.</p>
  <hr>
  <br>
	<p style="color: blue;">Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga, eligendi?</p>
	</body>
</html>
Tagged : / / / / / / /