The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to assign multiple classes to one html element

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
How to assign multiple classes to one html element Posted: Aug 24, 2016 9:55 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: How to assign multiple classes to one html element
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • In HTML if we want to apply any styles to any elements we will use cascading style sheets.
  • By using CSS we can apply styles to an element in HTML
  • If some style is needed for more than one type of element then we cant make a style and name it and where ever that style is required we can place that style for that element.

  • So like this it is always possible to apply multiple styles or multiple classes to HTML elements.
  • We can specify more than one CSS class to an element.
  • By using class attribute we can specify multiple  CSS classes to a single element and all classes must be separated by a space.
  • For example if we are applying multiple classes to a div tag.
  • <div class="class1 class2"></div>
  • Here class is the attribute and class1 and class2 are the two different CSS classes.
  • Lets take an example of one paragraph element and two css classes 
  • Fist we define a <p> element with no styles.
  • Second one more <p> element with one style
  • Third one more <p> element with two styles.  
  • HTML multiple classes

 

#1: Html example file to show how to assign multiple CSS classes to an HTML element :

 

  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <title>Cascading Style Sheet</title>
  5.  
  6. <style type="text/css">
  7.  
  8. .class1 {  
  9. text-align: center;
  10. color: red; 
  11. }
  12.  
  13. .class2 { font-size: 300%; }
  14.  
  15. </style>
  16. </head>
  17. <body>
  18. <p >   How to assign multiple classes to html element<p>
  19. <p class="class1">How to assign multiple classes to html element<p>
  20. <p class="class1 class2">How to assign multiple classes to html element<p>
  21.  
  22. </body>
  23. </html>


html multiple classes

Read: How to assign multiple classes to one html element

Topic: Android Studio for beginners, Part 1: Installation and setup Previous Topic   Next Topic Topic: 72% off Cambridge SoundWorks OontZ Angle 3 Wireless Bluetooth Speaker - Deal Alert

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use