Forum Moderators: not2easy
#slug1 .myclass #slug1 { display:block; background-color: #ffe; } for example. #stub1:myclass { css content } where "css content" would incude any color, spacing, padding, etc. changes you might want.
https://www.webmasterworld.com/css/5092445the slug is 5092445. Previously, each page slug called up separate CSS commands with its own identical ID, thus:
slug1 needs css ID #slug1
slug2 needs css ID #slug2
slug3 needs css ID #slug3 #stub1:myclass { css content }
.myclass {
background:#4d0000;
}
.myclass {background-color:#fff000}
#slug1 : .myclass
Every time I create a new page, I use a new set of CSS commands.If each page has its own CSS, wouldn't it be more straightforward to leave the variable parts on the page itself? Save external stylesheets for things that are shared by multiple pages.
<link rel="stylesheet" href="https://example.com/style.css" media="screen" type="text/css"> while inline styling might insert a line in the element only, as in: <div style="background-color:#fff000;"> I'm trying to figure out where the id="slug1" is found.
If each page has its own CSS, wouldn't it be more straightforward to leave the variable parts on the page itself? Save external stylesheets for things that are shared by multiple pages.The CSS blocks are all in the same file to make editing, copying and pasting easier because there are similarities. But like I said, I'm trying to reduce them to just five, to be used as needed by any of the fifty pages.
<div id="bd"> which is fine. That was the original developer's code and it works fine. I want to extend that formatting with a class of formatting commands: <div id="bd" class ="myclass"> Should this work? At the moment, it doesn't seem to be picking up the class at all. I've simplifed the class to just a background-color for testing, and even that doesn't register. Am I missing something? Thank you.
<div id="bd" class ="myclass"> try <div id="bd" class="myclass"> If there are conflicting descriptions with the id and class, the id will override class. If your id and class both specify different font-color for example, the id font-color will be used. I have never used a class within an id element and I don't think that is the correct syntax as used above, using them separately. <div id="bd: .myclass"> would be preferable, but I have no notes on using a class within an id element.
div[id|=foobar] {background-color: #669;}
meaning “If the element has an id, and the part before the hyphen--or the whole thing if there is no hyphen--is "foobar", then these styles apply.” In this example I used id, but it can be used with class as well. This syntax was especially meant for languages, so for example en-gb, en-us, en-au and so on could all share a style, but it's useful in other contexts. I use it most often in books with multiple illustrators, so each person's pictures (id in the form “rackham-1" "rackham-23" and so on) can be formatted differently. Thus: div[id|=rackham] p.caption {font-style: italic; color: #600;}
div[id|=hoppner] p.caption {font-family: BlackLetter; color: #600;}
div[id|=heath] p.caption {font-variant: small-caps;}
div[id|=hoppner] img {padding: 40px; background-color: #F7EEE6; border: 1px solid #EDC;}
I've gone into detail because you may be able to adapt it to your own situtation, such as giving all your pages an id in the form "green-1" "green-2" "red-3" and so on.
.myclass {
h3 {font-family:calibri;color:#8A4117;font-size:13pt;etc}
.h4 {font-family:calibri;color:#8A4117;font-size:9pt;etc}
}
.myclass h3 {styles here}
.myclass h4 {styles here}Spaces in css mean “something inside of something else”, in this case an h3 element inside of anything with classname "myclass". Nested braces are mainly used in @-rules, which you may not have got to yet :)
[edited by: not2easy at 2:28 am (utc) on Sep 4, 2023]
[edit reason] Sorry, no specifics please. (See ToS) [/edit]