Link to my forum: http://forum.inkscapecommunity.com
SMF version: 2.04
TP version: 1.107
Default Forum Language: English
Theme name and version: Aqua Style
Browser Name and Version: Firefox 21.0
Mods installed: approx 11 mods currently - tell me how to easily copy the list and I will :)
Related Error messages: none
Hi Friends,
Having recently learned not to have the wysiwyg html editor enabled, and to use only code for writing articles, I set about to finally write an article with the only kind of html I know, the very most basic kind. I was having trouble with <body background="url"> and <body bg=#color> tags, so I went to W3Schools.com to try and figure out what I was doing wrong. There I learned that those tags are not supported in HTML5. They seem to work ok in TP articles, but I thought I should update my skills, meager as they ever were.
So now I'm studying CSS. Since I was thinking that a TP article would be a single page, I thought I should use the Internal Style version of CSS, where the style is placed between style tags, in the same document as the rest of the code. That didn't seem to work very well, so I changed it to the Inline Style, which is about the same as the version of HTML that I already knew before, except that the style is written within each tag.
I have a test page, written both ways, and both of them work just fine in the browser. But when I plug them into a TP article, they seem to sort of coopt the code which creates the forum/portal itself -- so that parts of the forum/portal are actually in the article. I'll place both codes below, and a screenshot of the result (I could take the site out of maintenance mode, if you need to see the real thing, just lmk).
Internal Style:
<!DOCTYPE html>
<html>
<head>
<style>
body
{background-color:#ffffff;
background-image:url('http://forum.inkscapecommunity.com/tp-images/img/a-art2.png');
background-repeat:no-repeat;
background-position:center top;
font-size:100%;
font-family:Verdana,Geneva,sans-serif;
margin-right:20%;
margin-left:20%;}
h1
{text-align:center;
font-size:1.5em}
p
{font-size:1.2em}
</style>
</head>
<body>
<br>
<br>
<br>
<h1>How To Make A Screenshot</h1>
<p>text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article</p>
<p>More text.</p>
</body>
</html>
Inline Style:
<!DOCTYPE html>
<html>
<head>
<title>How To Make a Screenshot</title>
<head>
<body style="background-color:#ffffff;
background-image:url('http://forum.inkscapecommunity.com/tp-images/img/a-art2.png');
background-repeat:no-repeat;
background-position:center top;
font-size:100%;
font-family:Verdana,Geneva,sans-serif;
margin-right:20%;
margin-left:20%;">
<br>
<br>
<h1 style="font-size:1.5em;
text-align:center;">How To Make a Screenshot</h1>
<p style="font-size:1.2em;
text-align:left;">text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article</p>
<p style="font-size:1.2em;">More text.</p>
</body>
</html>
And I'll attach a screenshot of the result. Both codes give the same result, when placed in the TP article.
My questions:
--Which part of the CSS should I use, to write a TP article, so that it doesn't interfere with the SMF/TP code itself?
--Can the regular External Style Sheet version of CSS be used for a TP article? For example, if I wanted to write a series of articles, could I just use 1 style sheet for all of them? If so, how?
Thanks for your help :)
Edit -- added support info above :)
A couple of things. Putting code into articles (and even blocks) it's not necessary to treat it like a stand alone HTML page. For example, you don't need to declare a doctype or header etc. The reason is because your code is being included into a page that has already taken care of those things. So you are essentially breaking the HTML validation by including it.
You could break your code down to simply this:
<style>
body
{background-color:#ffffff;
background-image:url('http://forum.inkscapecommunity.com/tp-images/img/a-art2.png');
background-repeat:no-repeat;
background-position:center top;
font-size:100%;
font-family:Verdana,Geneva,sans-serif;
margin-right:20%;
margin-left:20%;}
h1
{text-align:center;
font-size:1.5em}
p
{font-size:1.2em}
</style>
<br>
<br>
<br>
<h1>How To Make A Screenshot</h1>
<p>text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article</p>
<p>More text.</p>
If you don't want your code to be affected by other styles in SMF or TP, you simply need to use unique names for classes and ID's in your html. This is how I'd prefer to write the code. Assigning a unique class I can then control all the items inside that class.
<style>
.myClass {
background-color:#ffffff;
background-image:url('http://forum.inkscapecommunity.com/tp-images/img/a-art2.png');
background-repeat:no-repeat;
background-position:center top;
font-size:100%;
font-family:Verdana,Geneva,sans-serif;
margin-right:20%;
margin-left:20%;
}
.myClass h1 {
text-align:center;
font-size:1.5em;
}
.myClass p {
font-size:1.2em;
}
</style>
<div class="myClass">
<br />
<br />
<br />
<h1>How To Make A Screenshot</h1>
<p>text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article, text of article</p>
<p>More text.</p>
</div>
You can of course add any styles, classes, id's to a stylesheet and then include that stylesheet in your code if you'd like. But that means altering a file every time you want to change something.
Thanks for coming up with this topic brynn!
And thanks for the great hints IchBin.
In addition to your question (I guess I had the same level of understanding like your some weeks ago):
Quote--Can the regular External Style Sheet version of CSS be used for a TP article? For example, if I wanted to write a series of articles, could I just use 1 style sheet for all of them? If so, how?
I made a separate CSS file and use simply the link in all articles:
<link rel="stylesheet" type="text/css" href="name of the file.css" />after that simply the body html it self and the css file it self it is the simple style of IchBins second suggestion.
Works wonderful and easy to handle after on it it is thoughtful developed.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsangham.net%2FSmileys%2Fsangham%2Fsadhu_sangham_sw.gif&hash=fb1cc408d4e8c070a005620020203edeec2d4e75)
Ok, yes, IchBin, I knew that somehow I had to make the code unique to my article (or series of articles). I had actually posted a topic at the W3Schools forum, asking if I could use the class selector on the body tag element. I didn't think that was exactly right. But they didn't know enough about SMF and TP to be able to help. (Well, at least not initially. That was as of last night. Maybe there will be another reply today.)
Thank you for your example of code. So it looks like, in your 1st example, you used the Internal Style variety, except without the <html> and <head> tags.
I understand generally what the class selector does (and sort of understand ID). But I don't understand exactly what you mean by
QuoteIf you don't want your code to be affected by other styles in SMF or TP, you simply need to use unique names for classes and ID's in your html.
For example, if I use the code from your 1st example, do you mean that it still might either affect, or be affected by other SMF/TP styles. Can you give me an example of what could happen?
The reason I'm asking, is that I fairly well understand your 1st example of code. But I haven't quite got the class selector worked out yet. I mean, all I need is more practice, to be able to use it. But I want to understand more specifically why I might need to use it.
(Just to explain what we'll need -- most of the articles will be tutorials. I'll make some tutorials to help members learn how to write articles and use the site, and members and I both will make tutorials for Inkscape (vector graphics editor). So we'll basically need text and image illustrations in the articles, and maybe some links. If, and that's a BIG IF, I can figure out how to do it, I'd like to create a sort of an article template that would make all the tutorials / articles have some similar styles. I thought I saw something about that somewhere, in the TP documentation?)
Regarding how you used the class selector in the 2nd example.....I thought the class had to be sort of like attached to something. So where you have .myClass h1 and .myClass p, the class is applied to <h1> and <p> elements. But above that, it's just .myclass. The W3Schools tutorial was really brief about class, but I'll go through it again, and try to understand more. But this may well be the answer to the question I asked them.
1 last question about the 2nd code example, where you used class -- I notice you changed
<br> to
<br />. Why?
Johann, yes, that sounds exactly like what I was thinking. But what I don't understand, is where do I put the CSS file? Do I upload it to the server somewhere? Like in forum / tp-files / tp-articles? I understand about having each article document link to the style sheet, but I don't understand exactly where the style sheet resides.
It seems like they should be there somewhere, but I haven't located any articles I've made, on the server. If I could find them, I'd try putting a style sheet there. But so far, I don't know where that is.
This is a little off topic, but regarding the image you see in my code, I just guessed about where to put it. (It's basically sort of a picture frame, so that it looks like the article has a border around the page.) I put it in forum / tp-files / tp-images / img (I created the img dir there.) But just looking through the server's file manager, I see forum / tp-files / tp-articles / images. Maybe that would be a better place for images that will appear in the articles?
Thanks again :)
Edit -- Oh, I see. On further inspection of IchBin's 1st sample of code, it looks like body tags were just left out. It's just the style tag, and then the content below the style. But no body tags around the content. At first I thought he had just chopped off the top and bottom of the whole code. But I guess it's the body tag that's causing the problem, right?
Edit #2 -- Bad news. I inserted your 1st code into an article, but it still looks like in my attachment screenshot. I removed the html, body and head tags, and the original 1st line of the code (I forget what it's called). But the problem still happens. :(
(I love your smileys here. Are they available for others forums to use?)
Hhmmm....Ok, I guess that's what you meant by
QuoteIf you don't want your code to be affected by other styles in SMF or TP, you simply need to use unique names for classes and ID's in your html.
So I guess I just need to go back and study on the class selector. Ok, I'm off to study more. Can you please leave this topic open, until I can get the code right? I won't disappear. It may be a couple of days, but I will report back on either my results, or any other problems I might have.
Thanks again for your help :)
Dear brynn,
I really understand your "troubles".
QuoteJohann, yes, that sounds exactly like what I was thinking. But what I don't understand, is where do I put the CSS file? Do I upload it to the server somewhere? Like in forum / tp-files / tp-articles? I understand about having each article document link to the style sheet, but I don't understand exactly where the style sheet resides.
Put the file you have made, where ever you want on your server. Maybe you make a folder "css" in your main directory (or domain) and maybe you call your first css "my_tp_aritcle (the file name of your css file)"
So you copy (upload) your "my_tp_aritcle.css" in your made folder "css" on your main ftp directory and the line you put into the article at the first place is:
<link rel="stylesheet" type="text/css" href="http://mywebsite.oh/css/my_tp_aritcle.css" />
It will load the css you have linked and use the "codes"/style for your article.
Take your time! When become stressed, just do something else for a while. No need to worry and I thing TP and IchBin will not run away of even close your topic.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsangham.net%2FSmileys%2Fsangham%2Fsadhu_sangham_sw.gif&hash=fb1cc408d4e8c070a005620020203edeec2d4e75)
brynn,
The only difference really between a class and an id is that id's are only supposed to be on a page once. Classes can be used as many times as you want.
.myClass p {
font-weight: bold;
}
This type of selector means that any paragraph located inside an HTML element that has class="myClass" will get bold font.
For example, only the middle div in the following code will have bold text.
<style type="text/css">
.myClass p {
font-weight: bold;
}
</style>
<div class="customClass"><p>Some text here</p></div>
<div class="myClass"><p>Some text here</p></div>
<div class="customClass"><p>Some text here</p></div>
Using <br / > instead of < br > is XHTML compliant. That means all tags have to have a close. Both will work, but tags need to have the close if you want your code to validate.
If you have something like this:
p {
font-size: 20px;
}
This means all paragraphs get a font size of 20px on your page. Unless you have specifically overridden that rule with another. That's why I say use unique names on your CSS classes and id's. This way, SMF or TP cannot override any CSS that you add to your HTML elements. There's a lot to learn about CSS. You'll have fun doing it. It's one of the easier languages of the web. But it can get really complicated if you let it. :)
Feel free to post back if you have any questions.
Oh, great news!
I've got a page working, even inside TP, using the Internal Style sheet variety. I will definitely be looking to make an External Style sheet that would apply to all the articles. But with all the elements, and class elements, and stuff, I'll need to have a very detailed plan regarding which style elements are given in the external style sheet, which ones in classes and divs, etc.
So we can close this topic now, since my original problem is now solved, plus a couple more problems, lol. I shouldn't have any trouble with the external style sheet. But if I do, I'll start a new topic.
Since my forum is still under development, it's not open yet. But here's a screenshot of a simple page. I went through some contortions trying to get a border around the whole article, because of needing to be viewed on so many different kinds of screens/resolutions. But I finally realized that if I use only a border along the left side, it wouldn't matter what kind of screen that website visitors have.
Thank you very much for your assistance. I really appreciate it :)
Well you have chosen the frame of the endless knot as I see, that will last a little ;)
One of the things you might want to know about. You can use the custom template in your category settings. This will apply the custom template to all articles in that category. The custom template looks like this by default:
<div class="tparticle">
<div class="cat_bar">
<h3 class="catbg"><span class="left"></span>{article_shortdate} {article_title} {article_category}</h3>
</div>
<div class="windowbg2">
<span class="topslice"><span></span></span>
<div class="content">
{article_avatar}
<div class="article_info">
{article_author}
{article_date}
{article_views}
{article_rating}
{article_options}
</div>
<div class="article_padding">{article_text}</div>
<div class="article_padding">{article_moreauthor}</div>
<div class="article_padding">{article_bookmark}</div>
<div class="article_padding">{article_morelinks}</div>
<div class="article_padding">{article_globaltags}</div>
<div class="article_padding">{article_comments}</div>
</div>
<span class="botslice"><span></span></span>
</div>
</div>
When TP parses that custom template, the places that have stuff like {article_comments} will be replaced with the actual comments of the article. You could come up with your template and save it in the category settings. You can add all the html/css you need in that template. Then you will have all the things you need up to a point. You could code that custom template to include your background and/or border etc. Could be a time saver for you.
Oh yes, I like the idea of having all the articles of certain categories having a certain style. And now that I understand class selector, I sort of understand that code. But where is the definition of the classes? For example, "tparticle" or "catbg" or "windowbg2"? Is that whatever style I decide to use?
I'm still a little fuzzy about those layout options for categories (and frontpage). But I will keep in mind that has something to do with how the articles look like. Eventually I'll understand, sooner or later, lol.
Those classes are likely in the themes index.css file. As long as the classes that you choose to use are available somewhere, either in the code itself or in a file you've added to your theme etc., it should find them.
OK like Brad suggested, If you are running the SMF 2.0 + the index.css is where you'd edit the styles, ( look and schemes ) The Front page, using TP should inherit the same themes setting, unless you selected another theme when you set up your Front page and if did set to another Theme for an article, you made go to TP > Submissions > select the edit and go to the bottom of the page that"s opens and elect the theme you want to utilize for this page!
Note: that you will then need to Tweak the index.css for that theme you selected for this page or article.
In order to edit the them u are using at present go the Admin > current theme > click on "Modify the stylesheets. (colors, fonts, etc.)" a set of windows will open the bottom window, you may edit the index.css code as needed!
This post id to benefit the general users..just in case LOL!
If you need help editing the TP styles, please let me know, but don't think they are related to this request!/?
regards,
Maxx
regards,
Maxx
Dear Maxx1,
I am not sure if that general theme change is that what the OP is about but also great to know, but I can be wrong for sure. Just thought to mention that, as brynn or a newcomer like me could easy get confused and cause little disasters with some experiments. (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsangham.net%2FSmileys%2Fsangham%2Fsmile_sangham_sw.gif&hash=dcc2ffb69576b648335176a01087e87ae0f5b5bd)
Thanks how every for you hints.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsangham.net%2FSmileys%2Fsangham%2Fsadhu_sangham_sw.gif&hash=fb1cc408d4e8c070a005620020203edeec2d4e75)
Please always keep a back up copy of anything you are planning to experiment with, I and other are always saying this.
Brad has also created a video how to you can find on YouTube, shows how to edit and customized you SMF themes, and I'm certain if you search there and the web you will also find other as well.
Please keep in mind, that if you are new to the web, that most any information can be found with the search!
if nothing else works, please ask someone!
regards,
Maxx
regards,
Maxx