Forum Moderators: not2easy
Can anybody suggest alternatives if this is not the way to go?
n.b. For my main page, it doesn't make sense to use <h1> in the usual heading sense, because the name of my organization already appears in a big graphics logo on top.
CSS:
h1#indexpage {
display: inline;
font: bold 16px verdana;
}
HTML:
<p> <h1 id="indexpage"> Widgets.com </h1 id="indexpage">
is the best place to buy widgets. Blah, blah blah...</p>
Thanks in advance.
A. rank for 'widget' => leave 's.com' not attached to the keyword in the code, but is visibly
or
B. rank for your org, 'widgets.com' => h1 not needed, use <span
things to consider,
improper use of code structure, <h1 then <p
why not use the name twice, you want people to remember as well as the spider
p.s. loose all attributes in the </h1>, not all software(spiders) will recognise </h1 something>
Hello kiril, the tag above is not correct syntax. It is also incorrect nesting of elements. Here would be the correct use of the <h> and <p> tags...
<h1 id="indexpage">Widgets.com</h1>
<p>The best place to buy widgets. Blah, blah blah...</p>
I can see that you are trying to increase the relevance of that text but, there are more elegant ways to do this. For one, since you cannot nest that <h> element in there, you could use the <strong> element...
<h1>Industrial Widgets for Sale</h1>
<p><strong>Widgets.com</strong> is the best place to buy widgets. Blah, blah blah...</p>
Assuming you wanted to get the most rankings boost for "Widgets" then does anybody have any opinions on which of the six ways would work best - or is there no difference. Note: I believe following examples all appear the same to the user.
<font size="+1"><b>Widgets</b></font>
<h3>Widgets</h3>
<h1><font size="+1">Widgets</font></h1>
h1#head { font-size: medium; font-weight: bold}
<h1 id="head">Widgets</h1>
.head { font-size: medium; font-weight: bold}
<span class="head">Widgets</span>
h1 { font-size: medium; font-weight: bold}
<h1>Widgets</h1>
I vote for either option 6 or option 4. Option 4 if you need to reference the id elsewhere; 6 otherwise. Those are the best options HTML-wise, at least. Hopefully Google picks up on the <h1>.
h1#indexpage {
display: inline;
font: bold 16px verdana;
}
h1#indexpage+p {
display: inline;
}
<h1 id="indexpage">Widgets.com</h1> <p>is the best place to buy widgets. Blah, blah blah...</p>
For most browsers, IE as well:
h1.indexpage {
font: bold 16px verdana;
}
.indexpage {
display: inline;
}
<h1 class="indexpage">Widgets.com</h1> <p class="indexpage">is the best place to buy widgets. Blah, blah blah...</p>
Dr. Doc' solution works very well:
-------
h1.indexpage {
font: bold 16px verdana;
}
.indexpage {
display: inline;
}
<h1 class="indexpage">Widgets.com</h1> <p class="indexpage">is the best place to buy widgets. Blah, blah blah...</p>
-------
I'd like to follow up to make sure I understand some more general lessons about CSS--I hope somebody has the time to indulge me, because these things just aren't covered in my CSS books.
1) Is my understanding correct?:
a) .indexpage defines a class that can apply to any element
b) h1.indexpage defines additional styles for the case when indexpage is assigned to an h1
2) I'm assuming that both <h1> and <p> must be defined as "indexpage" classes so that one is "inline" with respect to the other. For this association to exist, do they need to be next to each other in the html? What if there was another element defined as "indexpage" later in the html?
3) Not to waste people's time, but I also don't know what this means: h1#indexpage+p
*** One thing I really need is a book (or website) that explains all the ways of declaring styles. Can anybody suggest a place to look? ***
Thank you all.
Kiril
w3.org defined the standards
css2 specifications [w3.org]
Eric Meyer's web site at [meyerweb.com...] is also worth looking at.
You should also look around the archives here, and lurk. I learnt most of my CSS from Meyer's books and lurking in this vicinity. (Not that I'm an expert, but I have been known to produce the odd bit of CSS that works)
element+other = Applies to all other elements when immediately preceded by element
p {
color: blue;
}
h1+p {
color: red;
}
<h1>Foobar</h1>
<p>Lorem ipsum</p>
<p>Foo bar baz</p>
<p>Lorem ipsum dolor sit amet</p>
<h1>Widgets</h1>
<p>Foo bar baz</p>
a+span {
color: red;
font-weight: bold;
}
<a>Some link</a><br />
<a>Other link</a><br />
<a>Link again</a>
<span>Don't miss our special!</span><br />
<a>Foobar link</a><br />
<a>Widget link</a><br />