Topic: a simple question about marking up a link_to

Hi,
i have the following code:

<b><%= link_to post.title, :action => 'post', :id => post %></b>

but my title is not bold because the 'bold' tags contain the link tags,
how can i write this so my link is bold?

thank you

Re: a simple question about marking up a link_to

If you view source in your web browser, you should see that the link_to became was converted to the normal <a href...>. So you should be able to style it with css. Does that help?

Re: a simple question about marking up a link_to

thanks for the reply dkov, its going to be tricky for me to target that specific link to make it bold.
I am a bit of a stickler for semantic markup, so if the text should be bold, then i want to mark it up as bold.

That should be possible shouldnt it?

Re: a simple question about marking up a link_to

You can put the title in bold tags before handing it off to link_to

<%= link_to content_tag(:b, post.title), :action => 'post', :id => post %>

Or you can set the class of the anchor tag like this:

<%= link_to post.title, {:action => 'post', :id => post}, {:class => 'strong'} %>

# in css
.strong {
  font-weight: bold;
}

Railscasts - Free Ruby on Rails Screencasts

Re: a simple question about marking up a link_to

brilliant! thanks very much, just what i was looking for.

Re: a simple question about marking up a link_to

pingu wrote:

thanks for the reply dkov, its going to be tricky for me to target that specific link to make it bold.
I am a bit of a stickler for semantic markup, so if the text should be bold, then i want to mark it up as bold.

That should be possible shouldnt it?

or you can use <strong> instead of <b>

--jake

---------------------------------------------------------------------
Rails Development - Agile rails consulting and development for startups on a budget
Flvorful Blog - Some ramblings
Flvorful's Open Source Projects - Some handy hacks for your rails projects.

Re: a simple question about marking up a link_to

Ill try that, but i am not sure that would be semantically correct for what i am doing, because i need to apply it at block level, not inline, but thanks anyway.

Re: a simple question about marking up a link_to

If we're getting technical, I don't think <b> is ever considered correct today and is completely deprecated. Markup should indicate what the text is, not what it looks like or where it's positioned. That's what stylesheets are for.

Re: a simple question about marking up a link_to

Well if you really want to get technical, the <b> tag isn't officially deprecated (it passes XHTML 1.0 Strict without warning), but its use is definitely discouraged. wink

Railscasts - Free Ruby on Rails Screencasts

Re: a simple question about marking up a link_to

friends don't let friends use <b>

Last edited by tortoise (2006-12-29 19:22:52)

Re: a simple question about marking up a link_to

so what do i use instead? <strong>